Solutions for day one

This commit is contained in:
Eric Wagoner 2021-12-01 15:52:20 -05:00
parent 568be798e2
commit a2292d251b
3 changed files with 2041 additions and 0 deletions

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
14.17.6

40
01/code.js Normal file
View File

@ -0,0 +1,40 @@
const fs = require('fs');
const inputArray = fs.readFileSync('input.txt').toString().split("\n");
// Part One
let increases = 0;
let previous;
for(i in inputArray) {
const value = parseInt(inputArray[i]);
if (previous && value > previous) {
increases++;
}
previous = value;
}
console.log(increases);
// Part Two
increases = 0;
previous = null;
let a;
let b;
let c;
for(i in inputArray) {
c = parseInt(inputArray[i]);
total = a + b + c;
if (a && b && c && total > previous) {
increases++;
}
a = b;
b = c;
previous = total;
}
console.log(increases);

2000
01/input.txt Normal file

File diff suppressed because it is too large Load Diff