this repo has no description
1# Day 01 2 3```elixir 4Mix.install([:kino_aoc]) 5``` 6 7## Setup 8 9<!-- livebook:{"attrs":"eyJhc3NpZ25fdG8iOiJwdXp6bGVfaW5wdXQiLCJkYXkiOiIxIiwic2Vzc2lvbl9zZWNyZXQiOiJBRFZFTlRfT0ZfQ09ERV9TRVNTSU9OIiwieWVhciI6IjIwMjUifQ","chunks":null,"kind":"Elixir.KinoAOC.HelperCell","livebook_object":"smart_cell"} --> 10 11```elixir 12{:ok, puzzle_input} = 13 KinoAOC.download_puzzle("2025", "1", System.fetch_env!("LB_ADVENT_OF_CODE_SESSION")) 14``` 15 16```elixir 17instructions = 18 puzzle_input 19 |> String.split("\n", trim: true) 20 |> Enum.map(fn <<dir>> <> rest -> 21 num = String.to_integer(rest) 22 23 if dir == ?R do 24 {div(num, 100), rem(num, 100)} 25 else 26 {div(num, 100), -rem(num, 100)} 27 end 28 end) 29``` 30 31<!-- livebook:{"branch_parent_index":0} --> 32 33## Part 1 34 35```elixir 36Enum.reduce(instructions, {50, 0}, fn {_rot, val}, {curr, sum} -> 37 next = Integer.mod(curr + val, 100) 38 39 {next, sum + if(next == 0, do: 1, else: 0)} 40end) 41|> elem(1) 42``` 43 44<!-- livebook:{"branch_parent_index":0} --> 45 46## Part 2 47 48```elixir 49<<0x434C49434B::40>> 50``` 51 52```elixir 53Enum.reduce(instructions, {50, 0}, fn {rot, val}, {curr, sum} -> 54 next = curr + val 55 56 pass = 57 cond do 58 curr == 0 and next < 0 -> 0 59 next not in 0..99 -> 1 60 rem(next, 100) == 0 -> 1 61 true -> 0 62 end 63 64 {Integer.mod(next, 100), sum + pass + rot} 65end) 66|> elem(1) 67``` 68 69<!-- livebook:{"offset":1324,"stamp":{"token":"XCP.pI2XE8mwBZJ1_5rOsosmoLh5-clSindOf0NN_piQhnU8r5baxfvJEHunCv7iXrvn3G43jfoHCFBZZK6KbxbIY0lzTJzKKWPrrl0bQ9S1RQvkk6dMv_LpnTv13HwNr3JYMw","version":2}} -->