Last active
March 14, 2020 13:15
-
-
Save sergey-kras/fc7d1a3803c4a9143f1120343fba2c1d to your computer and use it in GitHub Desktop.
yandex.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Задача 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