This commit is contained in:
Tyler Beckman 2024-12-02 21:56:05 -07:00
parent 492bf51c0d
commit a2f09799e5
Signed by: Ty
GPG key ID: 2813440C772555A4
2 changed files with 18 additions and 0 deletions

8
day3/part1.ts Normal file
View file

@ -0,0 +1,8 @@
export async function solve() {
const input = await Deno.readTextFile("./input.txt");
let sum = 0;
for (const match of input.matchAll(/mul\((\d{1,3}),(\d{1,3})\)/g)) {
sum += +match[1] * +match[2];
}
return sum
}

10
day3/part2.ts Normal file
View file

@ -0,0 +1,10 @@
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
}