Skip to content

Instantly share code, notes, and snippets.

View edorivai's full-sized avatar

Edo Rivai edorivai

View GitHub Profile
const fs = require("fs");
const file = fs.readFileSync(__dirname + "/input.txt", { encoding: "utf-8" });
const depths = file.split('\n').map(Number);
const threeMeasurements = depths.map((first, index) => {
if (index > depths.length - 3) return null;
const second = depths[index + 1];
const third = depths[index + 2];
return first + second + third;
}).filter(x => x != null);