advent-of-code-2023/day_1/part_1.ts
2023-12-02 16:09:05 +08:00

9 lines
219 B
TypeScript

import * as fs from "fs";
const sum = fs
.readFileSync("input", "utf8")
.replace(/[^0-9\n]/g, "")
.split("\n")
.map((e) => parseInt(e[0] + e.at(-1)))
.reduce((sum, value) => sum + value, 0);
console.log(sum);