Advent of Code 2023 - Day 15
Mix.install([
{:kino, "~> 0.11.0"},
{:kino_aoc, github: "ljgago/kino_aoc"}
])
Input
{:ok, puzzle_input} =
KinoAOC.download_puzzle("2023", "15", System.fetch_env!("LB_AOC_SESSION"))
input =
puzzle_input
|> String.split(",", trim: true)
|> Enum.map(&String.to_charlist/1)
Part 1
hash = fn chars ->
Enum.reduce(chars, 0, fn c, acc ->
acc
|> Kernel.+(c)
|> Kernel.*(17)
|> Kernel.rem(256)
end)
end
input
|> Stream.map(hash)
|> Enum.sum()
Part 2