advent-of-code-2024/day3/part2.ts
2024-12-02 22:15:41 -07:00

10 lines
No EOL
344 B
TypeScript

export async function solve() {
const input = await Deno.readTextFile("./input.txt");
let sum = 0;
for (const part of input.split("do()").slice(1).map(e => e.split("don't()")[0])) {
for (const match of part.matchAll(/mul\((\d{1,3}),(\d{1,3})\)/g)) {
sum += +match[1] * +match[2];
}
}
return sum
}