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

Day 1

aoc/2021/elixir/day1.livemd

Day 1

Section

https://adventofcode.com/2021/day/1

https://adventofcode.com/2021/day/1/input

input =
  Stream.iterate("", fn _ -> IO.gets("input") end)
  |> Stream.take_while(&(&1 != :eof))
  |> Stream.map(&String.trim/1)
  |> Stream.reject(&(&1 == ""))
  |> Enum.map(&String.to_integer/1)
  |> Enum.to_list()
[hd | tail] = input

tail
|> Enum.reduce({hd, 0}, fn i, {p, c} -> if i > p, do: {i, c + 1}, else: {i, c} end)