Advent of Code solutions written in Gleam. Browse the solution wiki for tag/difficulty indexes, or see per-year pages in each src/year_XXXX/ folder.
45 problems solved across 11 years — Tags · Difficulty · Benchmarks
Years: 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025
| Day | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | ⭐ | ⭐ | ⭐ | ⭐ | ⭐ | ⭐ | ⭐ | ⭐ | ⭐ | ⭐ | ⭐ |
| 2 | ⭐ | ⭐ | ⭐ | ⭐ | ⭐ | ⭐ | |||||
| 3 | ⭐ | ⭐ | ⭐ | ||||||||
| 4 | ⭐ | ⭐ | |||||||||
| 5 | ⭐ | ⭐ | |||||||||
| 6 | ⭐ | ⭐ | |||||||||
| 7 | ⭐ | ⭐ | ⭐ | ||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | ⭐ | ||||||||||
| 11 | |||||||||||
| 12 | ⭐ | ⭐ | ⭐ | ||||||||
| 13 | ⭐ | ||||||||||
| 14 | |||||||||||
| 15 | ⭐ | ||||||||||
| 16 | ⭐ | ||||||||||
| 17 | ⭐ | ||||||||||
| 18 | ⭐ | ⭐ | |||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | ⭐ | ⭐ | |||||||||
| 24 | ⭐ | ⭐ | |||||||||
| 25 | ⭐ | ⭐ |
graph 21 grid 7 shortest-path 7 bfs 6 implicit-graph 6 bitmask 3 dfs 3 set 3 brute-force 2 dijkstra 2 geometry 2 reduction 2 regex 2 scc 2 sort 2 topological-sort 2 arithmetic 1 backtracking 1 bron-kerbosch 1 circular-list 1 clique 1 encode 1 floyd-warshall 1 hash 1 linear-scan 1 linked-list 1 longest-path 1 min-cut 1 modular-algebra 1 n-sum 1 over-engineered 1 simulation 1 state-space-search 1 stoer-wagner 1 top-k 1 transpose 1 tree 1 tsp 1 validation 1 window 1
- Gleam installed
gleam deps downloadTo automatically fetch puzzle inputs, you can set your Advent of Code session key:
export AOC_SESSION_KEY=your_session_key_hereWithout this key, the scaffold tool will create an empty input file that you'll need to fill manually.
Run a specific day's solution:
gleam run -- --year <year> --day <day>Examples:
gleam run -- --year 2024 --day 1 # Run 2024 Day 1
gleam run -- --year 2023 --day 25 # Run 2023 Day 25Generate the boilerplate for a new day:
gleam run -m scripts/scaffold -- --year <year> --day <day>Examples:
gleam run -m scripts/scaffold -- --year 2024 --day 1
gleam run -m scripts/scaffold -- --year 2023 --day 15This will create:
src/year_YYYY/day_DD.gleam- Solution module with template codetest/year_YYYY/day_DD_test.gleam- Test moduleinputs/YYYY_DD.txt- Input file (auto-fetched if AOC_SESSION_KEY is set)
The scaffold tool will:
- Create necessary directories if they don't exist
- Skip files that already exist (safe to re-run)
- Fetch your personal puzzle input from adventofcode.com (if session key is provided)
gleam test # Run all testsaocgl/
├── src/
│ ├── aocgl.gleam # Main entry point
│ ├── common/ # Shared utilities
│ ├── scripts/
│ │ └── scaffold.gleam # Scaffolding tool
│ └── year_YYYY/ # Solutions by year
│ ├── runner.gleam # Year-specific router
│ └── day_DD.gleam # Individual day solutions
├── test/
│ └── year_YYYY/
│ └── day_DD_test.gleam # Tests for each day
└── inputs/
└── YYYY_DD.txt # Puzzle inputsEach scaffolded solution follows this structure:
pub fn solve(raw_input: String) -> Solution {
let input = parse(raw_input)
let part_1 = solve_part_1(input) |> OfInt
let part_2 = solve_part_2(input) |> OfInt
Solution(part_1, part_2)
}
fn solve_part_1(input: List(Int)) -> Int {
// Implement part 1 solution
input |> list.length()
}
fn solve_part_2(input: List(Int)) -> Int {
// Implement part 2 solution
input |> list.length()
}
fn parse(raw_input: String) -> List(Int) {
// Parse input into desired format
}Please note that using list.length() and assuming this will be a Solution(OfInt, OfInt) was just me being lazy and since most of Advent of Code problems have List(Int) like expectations, I did it instead of todo-s - so that I can edit less.
gleam run # Run the project
gleam test # Run the tests
gleam build # Build the projectEvery solution has its own main so that we can echo parts of it as we develop and run it with gleam run -m year_<year>/day_dd for quicker feedbacks.
After solving a new puzzle, regenerate the wiki with:
python3 scripts/gen_wiki.pyThis will rebuild wiki/Home.md, wiki/tags/, wiki/difficulty.md, and each src/year_XXXX/README.md from the /// Title/Link/Difficulty/Tags doc comments at the top of every solved day file. Then just commit the results.
Make sure your solution file starts with the standard header:
/// Title: Your Puzzle Title /// Link: https://adventofcode.com/YYYY/day/DD /// Difficulty: xs | s | m | l | xl /// Tags: tag1 tag2 tag3
Feel free to explore different approaches and optimizations for the solutions!
This project is for educational purposes and personal development.