-
-
Save asonge/6d822b30d08da1d495a2372b7735e121 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function part1(input, days) { | |
let gens = [0,0,0,0,0,0,0,0,0] | |
input.split(',').forEach((x) => gens[x]++) | |
let zeroes = 0; | |
for(let d=0;d<days;d++) { | |
[zeroes, ...gens] = gens; | |
gens.push(zeroes) | |
gens[6] += zeroes | |
} | |
console.log(gens.reduce((a,b) => a+b)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment