Skip to content

Instantly share code, notes, and snippets.

@sergey-kras

sergey-kras/yandex.js

Last active Mar 14, 2020
Embed
What would you like to do?
yandex.js
/*Задача 1*/
function foo(config, stringa){
let count = 0;
stringa.split('').map(letter => {
let result = config.indexOf(letter);
if(result >= 0) count++;
});
return count;
}
/*Задача 2*/
function foo(config){
let result = 0;
let tmp = 0;
config.forEach((number) => {
if(parseInt(number) === 1) {
tmp++;
} else {
tmp = 0;
}
if(tmp > result) result = tmp;
});
return result;
}
/*Задача 3*/
let fs = require('fs');
let readline = require('readline');
let inStream = fs.createReadStream('./input.txt');
let outStream = fs.createWriteStream( './output.txt', { encoding: 'utf8'} );
outStream.writable = true;
let readLine = readline.createInterface({
input: inStream,
output: outStream,
terminal: false,
historySize: 0
});
let skipLine = true;
let prevLine;
readLine.on('line', function(line) {
if(skipLine || line === prevLine) {
skipLine = false;
} else {
outStream.write(line + '\n');
prevLine = line;
}
});
readLine.on('close', () => {
outStream.close();
inStream.close();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.