Created
January 4, 2019 14:37
-
-
Save 73nko/e9ac025722c610b54e833c75ac64e2c2 to your computer and use it in GitHub Desktop.
Base code for algorithms Course in Node 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
'use strict'; | |
const fs = require('fs'); | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf-8'); | |
let inputString = ''; | |
let currentLine = 0; | |
process.stdin.on('data', inputStdin => { | |
inputString += inputStdin; | |
}); | |
process.stdin.on('end', _ => { | |
inputString = inputString.replace(/\s*$/, '') | |
.split('\n') | |
.map(str => str.replace(/\s*$/, '')); | |
main(); | |
}); | |
function readLine() { | |
return inputString[currentLine++]; | |
} | |
// Complete the sockMerchant function below. | |
function sockMerchant(n, ar) { | |
} | |
function main() { | |
const ws = fs.createWriteStream(process.env.OUTPUT_PATH); | |
const n = parseInt(readLine(), 10); | |
const ar = readLine().split(' ').map(arTemp => parseInt(arTemp, 10)); | |
let result = sockMerchant(n, ar); | |
ws.write(result + "\n"); | |
ws.end(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment