day3
This commit is contained in:
9
day3/pt1.ts
Normal file
9
day3/pt1.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
const input = await Bun.file('./inputs/day3').text();
|
||||
const regex = /mul\((?<first>\d+)\,(?<second>\d+)\)/g;
|
||||
|
||||
const total = input
|
||||
.matchAll(regex)
|
||||
.map(({ groups }) => Number(groups!.first) * Number(groups!.second))
|
||||
.reduce((curr, acc) => curr + acc);
|
||||
|
||||
console.log(`sum of mult: ${total}`);
|
||||
Reference in New Issue
Block a user