commit 3cf14a15b169c945789620fac8d231682ef41680
parent d9a3b9fb9cab0c3c7c7c83fdc5556c66af337971
Author: Eamon Caddigan <eamon.caddigan@gmail.com>
Date: Sat, 7 Jan 2023 17:45:57 -0800
Solution to day 23, part 2.
Maybe; it's untested because I'm on a plane. [Updating my commit message
to say that yes, it does indeed work ^_^]
Diffstat:
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/day_23.jl b/src/day_23.jl
@@ -134,7 +134,26 @@ end
@assert part_1(example) == 110
@info part_1(input)
+function Base.:(==)(elves₁::Dict{Elf,Elf}, elves₂::ElfSet)
+ keys(elves₁) == elves₂
+end
+
+function Base.:(==)(elves₁::ElfSet, elves₂::Dict{Elf,Elf})
+ elves₁ == keys(elves₂)
+end
+
+function Base.:(==)(elves₁::Dict{Elf,Elf}, elves₂::Dict{Elf,Elf})
+ keys(elves₁) == keys(elves₂)
+end
+
function part_2(input)
+ elves₁ = parse_input(input)
+ for ts = 0:1_000_000
+ elves₂ = moveelves(elves₁, ts)
+ elves₁ == elves₂ && return ts+1
+ elves₁ = elves₂
+ end
nothing
end
+@assert part_2(example) == 20
@info part_2(input)