NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

function checkIP (arr) {
const result = [];

for (let str of arr) {
if (checkIPv6(str)) {
result.push('IPv6');
continue;
}

if (checkIPv4(str)) {
result.push('IPv4');
continue;
}

result.push('Neither');
}

return result;
}

function checkIPv6(str) {
let strArr = str.split(':');

if (strArr.length !== 8) {
return false;
}

for (let str of strArr) {
if (str.length > 4 || str.length === 0) {
return false;
}

for (let ch of str) {
if (!ch.match(/[a-f0-9]+/i)) {
return false;
}
}
}

return true;
}

function checkIPv4(str) {
let strArr = str.split('.');

if (strArr.length !== 4 || str.length === 0) {
return false;
}

for (let str of strArr) {
const num = Number(str);
if (Number.isNaN(num) || num < 0 || num > 255) {
return false;
}
}

return true;
}
var a = [
'2001:0db8:0000:0000:0000:ff00:0042:8329',
'172.16.254.1',
'222.223.240.298',
'222.223.240.222a',
]

console.log(checkIP(a));

function decrypt(str) {
const key = '2512208'.split('').map(Number);
let result = new Array(str.length);

for (let i = 0, j = 0; i < str.length; i++) {
if (!str[i].match(/[a-zA-Z]/)) {
result[i] = str[i];
continue;
}

let charCode = str.charCodeAt(i);
if (charCode > 96) {
charCode = (charCode - key[j] - 97 + 26) % 26 + 97;
} else {
charCode = (charCode - key[j] - 65 + 26) % 26 + 65;
}

result[i] = String.fromCharCode(charCode);
j = (j + 1) % key.length;
}

return result.join('');
}

var a = '-Atvt hrqgse, Cnikg';
console.log(decrypt(a));
// var a = 'Otjfvknou kskgnl, K mbxg iurtsvcnb ksgq hoz atv. Vje xcxtyqrl vt ujg smewfv vrmcxvtg rwqr ju vhm ytsf elwepuqyez. -Atvt hrqgse, Cnikg';
// console.log(decrypt(a));

function informationMasking(input) {
input = input.trim();
if (input[0] === 'E') {
const firstCharIndex = input.slice(2).search(/[a-zA-z0-9!#$%&'*+-/=?^`{|}~]/, 2) + 2;
const emailIndex = input.lastIndexOf('@');
return input.slice(0, firstCharIndex + 1) + '*****' + input.slice(emailIndex - 1);
}

if (input[0] === 'P') {
const result = [];
const numbers = input.match(/[0-9]/g);

let i = numbers.length - 1;
if (i >= 4) {
result.push(numbers[i--]);
result.push(numbers[i--]);
result.push(numbers[i--]);
result.push(numbers[i--]);
}

while (i >= 2) {
result.push('-');
result.push('*');
result.push('*');
result.push('*');
i -= 3;
}

while (i >= 0) {
result.push('*');
i--;
}


if (input.indexOf('+') != -1) {
result.push('+');
}

return result.reverse().join('');
}
}

var a = 'E: [email protected]'
console.log(informationMasking(a));
var a = 'P: +13334445678'
console.log(informationMasking(a));
var a = 'P: +1 (333) 444-5678'
console.log(informationMasking(a));
var a = 'P: +91 (333) 444-5678'
console.log(informationMasking(a));
var a = 'P: +111 (333) 444-5678'
console.log(informationMasking(a));
var a = 'P: 333 444-5678'
console.log(informationMasking(a));
var a = 'P: (333) 444-5678'
console.log(informationMasking(a));

function maxLength(a, k) {
let max = 0;
let start = 0;
let cur = 0;

for (let i = 0; i < a.length; i++) {
cur += a[i];

while (cur > k && start <= i) {
cur -= a[start++];
}

if (cur === k) {
return cur;
}

if (cur > max && cur < k) {
max = cur;
}
}

return max;
}

var a = [1, 22, 3, 4, 5, 1];
console.log(maxLength(a, 13));

function getRecommendedTweets(fG, lG, targetUser, minLikeThreshold) {
const userFollows = {};
const tweetLikes = {};

for (let tuple of fG) {
if (tuple[0] === targetUser) {
userFollows[tuple[1]] = true;
}
}

for (let tuple of lG) {
if (userFollows[tuple[0]]) {
tweetLikes[tuple[1]] = ++tweetLikes[tuple[1]] || 1;
}
}

return Object.keys(tweetLikes).filter(k => {
return tweetLikes[k] >= minLikeThreshold;
});
}

var a = [['A', 'B'], ['A', 'C'], ['B', 'C'], ['D', 'A'], ['D', 'B']];
var b = [['A', 'T1'], ['B', 'T2'], ['A', 'T2']];
console.log(getRecommendedTweets(a, b, 'D', 1));

// process.stdin.resume();
// process.stdin.setEncoding('ascii');

// var input_stdin = "";
// var input_stdin_array = "";
// var input_currentline = 0;

// process.stdin.on('data', function (data) {
// input_stdin += data;
// });

// process.stdin.on('end', function () {
// input_stdin_array = input_stdin.split("n");
// main();
// });

// function readLine() {
// return input_stdin_array[input_currentline++];
// }

// /////////////// ignore above this line ////////////////////

// function main() {
// var n_temp = readLine().split(' ');
// var n = parseInt(n_temp[0]);
// var k = parseInt(n_temp[1]);
// x = readLine().split(' ');
// x = x.map(Number);

// }
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.