Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require('fs');
- const eol = require('os').EOL;
- const arg = process.argv.slice(2);
- const file = arg[0] == "test" ? "/test.txt" : "/data.txt";
- const startTime = new Date().getTime();
- let input = fs.readFileSync(__dirname + file, 'utf8');
- let data = input.split(eol + eol).map(val =>
- val.split(eol).map(Number).reduce((a, b) => a + b)
- ).sort((a, b) => b - a)
- console.log('Part 1: ' + data[0]);
- console.log('Part 2: ' + (data[0] + data[1] + data[2]));
- console.log('Timer: ' + (new Date().getTime() - startTime) + 'ms');
Advertisement
Add Comment
Please, Sign In to add comment