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

Advent of Code 2015 Day 4 Part 1

2015_day4_part1.livemd

Advent of Code 2015 Day 4 Part 1

Mix.install([
  {:kino_aoc, "~> 0.1"}
])

Get Inputs

{:ok, puzzle_input} =
  KinoAOC.download_puzzle("2015", "4", System.fetch_env!("LB_SESSION"))

My answer

Enum.find(0..10000000, fn index ->
  hash_head =
    :crypto.hash(:md5, "#{puzzle_input}#{index}")
    |> Base.encode16()
    |> String.slice(0..4)

  hash_head == "00000"
end)