Powered by AppSignal & Oban Pro

Day 6: Tuning Trouble

day-6-tuning-trouble.livemd

Day 6: Tuning Trouble

Mix.install([
  {:kino, "~> 0.7.0"}
])

Input

input = Kino.Input.textarea("Input")

Part 1

Kino.Input.read(input)
|> String.codepoints()
|> Enum.chunk_every(4, 1, :discard)
|> Enum.with_index()
|> Enum.find(fn {chunk, _} -> Enum.uniq(chunk) == chunk end)
|> (fn {code, x} -> length(code) + x end).()

Part 2

Kino.Input.read(input)
|> String.codepoints()
|> Enum.chunk_every(14, 1, :discard)
|> Enum.with_index()
|> Enum.find(fn {chunk, _} -> Enum.uniq(chunk) == chunk end)
|> (fn {code, x} -> length(code) + x end).()