2024 Day 14: at least add a path for the program to complete
This commit is contained in:
parent
83d6f89769
commit
aee0c29d53
1 changed files with 8 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue