aoc-2023/day_1/solve_part1.ts

7 lines
299 B
TypeScript
Raw Permalink Normal View History

2024-12-09 22:41:02 +09:00
const input = await Deno.readTextFile("input.txt");
const lines = input.split("\n");
const numbers = lines.map(line => {
const numbers = line.split("").filter(c => c.match(/[0-9]/));
return parseInt(numbers[0] + numbers[numbers.length - 1]);
});
console.log(numbers.reduce((a, b) => a + b));