aoc2021/6.jl

20 lines
353 B
Julia
Raw Normal View History

2021-12-22 10:33:30 +00:00
function solution6(n)
initial = parse.(Int, split(readline("6.data"),","))
fish = [count(initial .== i) for i in 0:8]
for _ in 1:n
fish = circshift(fish, -1)
fish[7] += fish[9]
end
sum(fish)
end
function solution6_1()
solution6(80)
end
function solution6_2()
solution6(256)
end
solution6_1(),solution6_2()