advent-of-code-2024/day3/part1.ts

8 lines
261 B
TypeScript
Raw Normal View History

2024-12-02 21:56:05 -07:00
export async function solve() {
2024-12-03 21:42:57 -07:00
const input = await Deno.readTextFile(import.meta.dirname + "/input.txt");
2024-12-02 21:56:05 -07:00
let sum = 0;
for (const match of input.matchAll(/mul\((\d{1,3}),(\d{1,3})\)/g)) {
sum += +match[1] * +match[2];
}
return sum
}