fix scaffolding, start d3
This commit is contained in:
parent
048cc9d4c2
commit
af91eb4ed5
6 changed files with 61 additions and 22 deletions
29
solutions/03.ts
Normal file
29
solutions/03.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
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())
|
||||
Loading…
Add table
Add a link
Reference in a new issue