Created
December 8, 2021 20:30
-
-
Save vijfhoek/af77973c3ad90ea3949d8d5b2cf36c8f 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
from std/strutils import split, parseInt | |
from std/sequtils import map, foldl | |
let numbers = readLine(stdin).split(',').map(parseInt) | |
var buckets: array[256 + 9, int] | |
for number in numbers: | |
buckets[number] += 1 | |
for i in 0..<256: | |
let fishies = buckets[i] | |
buckets[i] = 0 | |
buckets[i + 7] += fishies | |
buckets[i + 9] += fishies | |
if i == 80: | |
echo("part 1: ", buckets.foldl(a + b)) | |
echo("part 2: ", buckets.foldl(a + b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment