renamed 2 digit file names
This commit is contained in:
parent
018011dd27
commit
b4d985a55a
44 changed files with 0 additions and 0 deletions
21
2018/01/part2.js
Normal file
21
2018/01/part2.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
const fs = require('fs');
|
||||
|
||||
let input = fs.readFileSync('input.txt', 'utf-8');
|
||||
let freq = 0;
|
||||
let history = [0];
|
||||
found = false;
|
||||
while (!found) {
|
||||
for (let line of input.split('\n')) {
|
||||
num = parseInt(line);
|
||||
if (num) {
|
||||
freq += num;
|
||||
}
|
||||
if (history.includes(freq)) {
|
||||
found = true;
|
||||
break;
|
||||
} else {
|
||||
history.push(freq);
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(freq)
|
Loading…
Add table
Add a link
Reference in a new issue