2024 Day 14: at least add a path for the program to complete

This commit is contained in:
Adam Millerchip 2024-12-14 18:03:41 +09:00
parent 83d6f89769
commit aee0c29d53

View file

@ -59,10 +59,10 @@ defmodule Day14 do
# manually: noticed things looked suspicious after 27 seconds
# also noticed that repeated every 101 seconds
# Checked each 101 second jump until found the above tree
tick_forever(robots, size_x, size_y)
find_tree(robots, size_x, size_y)
end
def tick_forever(robots, size_x, size_y, count \\ 27, acc \\ 27) do
def find_tree(robots, size_x, size_y, count \\ 27, acc \\ 27) do
robots = tick(robots, size_x, size_y, count)
robomap = MapSet.new(robots, fn [x, y, _, _] -> {x, y} end)
@ -78,9 +78,13 @@ defmodule Day14 do
IO.puts("|")
end
IO.gets("#{acc} tree?")
line = IO.gets("#{acc} tree [y/N]?")
tick_forever(robots, size_x, size_y, 101, acc + 101)
if line |> String.trim() |> String.downcase() == "y" do
acc
else
find_tree(robots, size_x, size_y, 101, acc + 101)
end
end
def tick(robots, size_x, size_y, times) do