29 lines
No EOL
638 B
TypeScript
29 lines
No EOL
638 B
TypeScript
import { solvables } from "../main.ts";
|
|
|
|
import type { Day } from "../day.ts";
|
|
import { readInput } from "../utils.ts";
|
|
|
|
class DayImpl implements Day {
|
|
day = 3
|
|
input = readInput('03')
|
|
|
|
public part1(): Day {
|
|
const vals: string[] = this.input
|
|
.split("\n")
|
|
|
|
const result = vals.map(battery => {
|
|
const sorted = battery.split("").sort()
|
|
return Number.parseInt(sorted[0]) + Number.parseInt(sorted[1])
|
|
}).reduce((a, b) => a + b, 0)
|
|
|
|
console.log(result)
|
|
|
|
return this
|
|
}
|
|
|
|
public part2(): Day {
|
|
return this
|
|
}
|
|
}
|
|
|
|
solvables.push(new DayImpl()) |