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

Day 6: Tuning Trouble

2022/elixir/day-06.livemd

Day 6: Tuning Trouble

Mix.install([:kino])

Part 1

input = Kino.Input.textarea("Input")
input
|> Kino.Input.read()
|> String.to_charlist()
|> Stream.chunk_every(4, 1)
|> Enum.find_index(fn chars -> chars |> Enum.uniq() |> length() == 4 end)
|> Kernel.+(4)

Part 2

input
|> Kino.Input.read()
|> String.to_charlist()
|> Stream.chunk_every(14, 1)
|> Enum.find_index(fn chars -> chars |> Enum.uniq() |> length() == 14 end)
|> Kernel.+(14)