17 lines
369 B
Nim
17 lines
369 B
Nim
|
from std/strutils import split, parseInt
|
||
|
from std/sequtils import map, foldl
|
||
|
|
||
|
let numbers = readLine(stdin).split(',').map(parseInt)
|
||
|
var buckets: array[9, int]
|
||
|
|
||
|
for number in numbers:
|
||
|
buckets[number] += 1
|
||
|
|
||
|
for i in 0..<256:
|
||
|
buckets[(i + 7) mod 9] += buckets[i mod 9]
|
||
|
|
||
|
if i == 79:
|
||
|
echo("part 1: ", buckets.foldl(a + b))
|
||
|
|
||
|
echo("part 2: ", buckets.foldl(a + b))
|