Skip to content

Instantly share code, notes, and snippets.

@73nko
Created January 4, 2019 14:37
Show Gist options
  • Save 73nko/e9ac025722c610b54e833c75ac64e2c2 to your computer and use it in GitHub Desktop.
Save 73nko/e9ac025722c610b54e833c75ac64e2c2 to your computer and use it in GitHub Desktop.
Base code for algorithms Course in Node JS
'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