Files
aocutil/2021/6.js
nim-ka 0485b4f035 .
2022-11-19 22:52:51 +00:00

17 lines
346 B
JavaScript

function day6(input, part2) {
input = input.split(",").num()
let counts = Array(9).fill().map((_, i) => input.count(i))
for (let i = 0; i < (part2 ? 256 : 80); i++) {
counts.push(counts.shift())
counts[6] += counts[8]
}
return counts.sum()
}
if (typeof window == "undefined") {
module.exports = day6
}