trunk
HeNine 3 years ago
parent e68049b284
commit 91bbcf080c

@ -0,0 +1,4 @@
name = "day06"
uuid = "000671ab-97c2-4b62-8378-0d7f78995e06"
authors = ["HeNine "]
version = "0.1.0"

@ -0,0 +1 @@
1,4,2,4,5,3,5,2,2,5,2,1,2,4,5,2,3,5,4,3,3,1,2,3,2,1,4,4,2,1,1,4,1,4,4,4,1,4,2,4,3,3,3,3,1,1,5,4,2,5,2,4,2,2,3,1,2,5,2,4,1,5,3,5,1,4,5,3,1,4,5,2,4,5,3,1,2,5,1,2,2,1,5,5,1,1,1,4,2,5,4,3,3,1,3,4,1,1,2,2,2,5,4,4,3,2,1,1,1,1,2,5,1,3,2,1,4,4,2,1,4,5,2,5,5,3,3,1,3,2,2,3,4,1,3,1,5,4,2,5,2,4,1,5,1,4,5,1,2,4,4,1,4,1,4,4,2,2,5,4,1,3,1,3,3,1,5,1,5,5,5,1,3,1,2,1,4,5,4,4,1,3,3,1,4,1,2,1,3,2,1,5,5,3,3,1,3,5,1,5,3,5,3,1,1,1,1,4,4,3,5,5,1,1,2,2,5,5,3,2,5,2,3,4,4,1,1,2,2,4,3,5,5,1,1,5,4,3,1,3,1,2,4,4,4,4,1,4,3,4,1,3,5,5,5,1,3,5,4,3,1,3,5,4,4,3,4,2,1,1,3,1,1,2,4,1,4,1,1,1,5,5,1,3,4,1,1,5,4,4,2,2,1,3,4,4,2,2,2,3

@ -0,0 +1,53 @@
##
function task0(file)
fish = readline(file) |>
x -> split(x, ",") .|>
x -> parse(Int, x)
for generation = 1:80
fish = [🐟 == 0 ? [6, 8] : [🐟 - 1] for 🐟 fish] |> x -> vcat(x...)
end
length(fish)
end
##
println("Day 06 Task 1 Case 0")
open(task0, "day06\\data\\case00.txt") |> display
@assert open(task0, "day06\\data\\case00.txt") == 5934
println("Day 06 Task 1 Case 1")
open(task0, "day06\\data\\case01.txt") |> println
@assert open(task0, "day06\\data\\case01.txt") == 349549
##
function task1(file)
fish = readline(file) |>
x -> split(x, ",") .|>
x -> parse(Int, x)
🐠 = zeros(Int, 9)
for 🐟 fish
🐠[🐟+1] += 1
end
for generation = 1:256
🐠 = [🐠[2:7]; 🐠[1] + 🐠[8]; 🐠[9]; 🐠[1]]
end
sum(🐠)
end
##
println("Day 06 Task 2 Case 0")
open(task1, "day06\\data\\case00.txt") |> display
@assert open(task1, "day06\\data\\case00.txt") == 26984457539
println("Day 06 Task 2 Case 1")
open(task1, "day06\\data\\case01.txt") |> println
@assert open(task1, "day06\\data\\case01.txt") == 1589590444365
Loading…
Cancel
Save