You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
395 B
JavaScript
16 lines
395 B
JavaScript
const fs = require("fs")
|
|
|
|
const input = fs.readFileSync("input.txt", "utf-8", err => {
|
|
err && console.error(err)
|
|
}).split("\n").map(num => parseInt(num))
|
|
|
|
let partOne = 0, partTwo = 0
|
|
|
|
for (let i = 0; i < input.length; i++){
|
|
if (input[i - 1] && input[i] > input[i - 1])
|
|
partOne++
|
|
if (input[i - 3] && input[i] > input[i - 3])
|
|
partTwo++
|
|
}
|
|
|
|
console.log(partOne, partTwo) |