mirror of
https://github.com/Aviortheking/advent-of-code.git
synced 2025-04-22 10:52:11 +00:00
11 lines
338 B
TypeScript
11 lines
338 B
TypeScript
// note: this runs using bun!
|
|
const file = Bun.file('./input.txt')
|
|
const text = await file.text()
|
|
const res = text.split('\n').filter((it) => !!it).map((it) => {
|
|
const nums = it.replace(/[a-z]/g, '')
|
|
const first = nums[0]
|
|
const last = nums[nums.length - 1]
|
|
return parseInt(first + last)
|
|
}).reduce((p, c) => p + c, 0)
|
|
console.log(res)
|