advent of code 2025 in gleam!
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

day 1 part 1

+77 -2
+2
gleam.toml
··· 14 14 15 15 [dependencies] 16 16 gleam_stdlib = ">= 0.44.0 and < 2.0.0" 17 + simplifile = ">= 2.3.1 and < 3.0.0" 18 + gleam_regexp = ">= 1.1.1 and < 2.0.0" 17 19 18 20 [dev-dependencies] 19 21 gleeunit = ">= 1.0.0 and < 2.0.0"
+16
manifest.toml
··· 1 + # This file was generated by Gleam 2 + # You typically do not need to edit this file 3 + 4 + packages = [ 5 + { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" }, 6 + { name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" }, 7 + { name = "gleam_stdlib", version = "0.67.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "6368313DB35963DC02F677A513BB0D95D58A34ED0A9436C8116820BF94BE3511" }, 8 + { name = "gleeunit", version = "1.9.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "DA9553CE58B67924B3C631F96FE3370C49EB6D6DC6B384EC4862CC4AAA718F3C" }, 9 + { name = "simplifile", version = "2.3.1", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "957E0E5B75927659F1D2A1B7B75D7B9BA96FAA8D0C53EA71C4AD9CD0C6B848F6" }, 10 + ] 11 + 12 + [requirements] 13 + gleam_regexp = { version = ">= 1.1.1 and < 2.0.0" } 14 + gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } 15 + gleeunit = { version = ">= 1.0.0 and < 2.0.0" } 16 + simplifile = { version = ">= 2.3.1 and < 3.0.0" }
+3 -2
src/advent_2025.gleam
··· 1 + import day1 1 2 import gleam/io 2 3 3 - pub fn main() -> Nil { 4 - io.println("Hello from advent_2025!") 4 + pub fn main() { 5 + day1.day1main() 5 6 }
+40
src/day1.gleam
··· 1 + import gleam/int 2 + import gleam/list 3 + import gleam/string 4 + import herbie 5 + import simplifile 6 + 7 + pub fn day1main() { 8 + let assert Ok(file) = simplifile.read("./data/day1test") 9 + let file = 10 + file 11 + |> string.trim_end() 12 + |> string.split("\n") 13 + 14 + let moves = list.map(file, signed) 15 + list.fold(moves, #(50, 0), make_move) 16 + |> echo 17 + } 18 + 19 + fn crosses_zero(starting: Int, move: Int) -> Int { 20 + todo 21 + } 22 + 23 + fn make_move(acc: #(Int, Int), move: Int) -> #(Int, Int) { 24 + let position = { acc.0 + move + 100 } % 100 25 + let zeroes = case position { 26 + 0 -> acc.1 + 1 27 + _ -> acc.1 28 + } 29 + #(position, zeroes) 30 + } 31 + 32 + fn signed(input: String) -> Int { 33 + let graphemes = string.to_graphemes(input) 34 + let assert [sign, ..nums] = graphemes 35 + let nums = nums |> string.concat() |> herbie.quickint() 36 + case sign { 37 + "L" -> nums * -1 38 + _ -> nums 39 + } 40 + }
+16
src/herbie.gleam
··· 1 1 import gleam/dict 2 2 import gleam/int 3 3 import gleam/list 4 + import gleam/result 4 5 import gleam/string 5 6 import simplifile 6 7 7 8 pub type Coord = 8 9 #(Int, Int) 10 + 11 + pub fn quickint(input: String) -> Int { 12 + let assert Ok(return) = int.parse(input) 13 + return 14 + } 15 + 16 + pub fn quickfirst(input: List(a)) -> a { 17 + let assert Ok(return) = list.first(input) 18 + return 19 + } 20 + 21 + pub fn quicklast(input: List(a)) -> a { 22 + let assert Ok(return) = list.last(input) 23 + return 24 + } 9 25 10 26 pub fn path_to_string(path: String) -> String { 11 27 let assert Ok(return) = simplifile.read(from: path)