Files
adventofcode/day01/index.mjs
Thomas Ruoff 7343b0fe9e day1
2021-12-02 23:52:42 +01:00

19 lines
352 B
JavaScript

import * as readline from 'node:readline';
import * as fs from 'node:fs';
const rl = readline.createInterface({
input: fs.createReadStream('./input')
});
let last = null;
let counter = 0;
for await (const line of rl) {
const v = parseInt(line, 10);
if (last !== null && v > last) counter++;
last = v;
}
console.log(counter);