Powered by AppSignal & Oban Pro

Day 6: Tuning Trouble

2022/day_06.livemd

Day 6: Tuning Trouble

Mix.install([:kino])

input = Kino.Input.textarea("Please paste your input:")

Part 1

Run in Livebook

https://adventofcode.com/2022/day/6

find_marker = fn <<x::binary-size(1)>> <> rest, count, queue, fun ->
  new_queue = [x | queue]

  with 14 <- Enum.count(new_queue),
       14 <- new_queue |> Enum.uniq() |> Enum.count() do
    count
  else
    _ -> fun.(rest, count + 1, Enum.slice(new_queue, 0..(14 - 2)), fun)
  end
end

_answer2 =
  find_marker.(data, 1, [], find_marker)