Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

[WIP]: Day 22: Monkey Map -- AoC 22

2022/22.livemd

[WIP]: Day 22: Monkey Map – AoC 22

stream = File.stream!("/Users/pw/src/weiland/adventofcode/2022/input/22.txt")

Part One

chunk_fun = fn element, acc ->
  if element == "\n" do
    {:cont, acc, []}
  else
    {:cont, [String.trim(element) | acc]}
  end
end

after_fun = fn
  [] -> {:cont, []}
  acc -> {:cont, acc, []}
end

[row, path] = Enum.chunk_while(stream, [], chunk_fun, after_fun)

IO.inspect(path)

row

Part Two

stream
|> Enum.to_list()