๐ŸŽ„ advent of code 2025

day1 part1

okkdev 5c8c7784

Changed files
+55
day1
+2
.gitignore
··· 1 + aoc2025gleam/ 2 + input.txt
+43
day1/day1.gleam
··· 1 + import gleam/bit_array 2 + import gleam/int 3 + import gleam/list 4 + import gleam/result 5 + import gleam/string 6 + import simplifile 7 + 8 + pub fn main() { 9 + let assert Ok(raw_input) = simplifile.read("src/day1/test.txt") 10 + 11 + let input = 12 + raw_input 13 + |> string.trim 14 + |> string.split("\n") 15 + 16 + input 17 + |> list.fold(#(50, 0), fn(acc, x) { 18 + case x { 19 + "L" <> n -> { 20 + do_the_thing(n, acc, fn(a, b) { a - b }) 21 + } 22 + "R" <> n -> { 23 + do_the_thing(n, acc, fn(a, b) { a + b }) 24 + } 25 + _ -> panic as "what the helly" 26 + } 27 + }) 28 + |> echo as "Part 1" 29 + } 30 + 31 + fn do_the_thing( 32 + amount: String, 33 + state: #(Int, Int), 34 + operation: fn(Int, Int) -> Int, 35 + ) -> #(Int, Int) { 36 + let assert Ok(n) = int.parse(amount) 37 + let assert Ok(num) = operation(state.0, n) |> int.modulo(100) 38 + let password = case num { 39 + 0 -> state.1 + 1 40 + _ -> state.1 41 + } 42 + #(num, password) 43 + }
+10
day1/test.txt
··· 1 + L68 2 + L30 3 + R48 4 + L5 5 + R60 6 + L55 7 + L1 8 + L99 9 + R14 10 + L82