Skip to content

devries/advent_of_code_2025

Repository files navigation

Advent of Code 2025

Tests Stars: 18

This year will be my second year doing Advent of Code in Gleam. Last year I was still learning the language, and in the past year I have used it much more and even made some small contributions to the compiler, the gleam_time package, and maintain a timezone database and utility package called tzif. Gleam is a simple language with a wonderful community. I encourage anyone interested in Gleam to take the language tour and use the playground.

To start a new day's problem use the command

gleam run new --day=1

where 1 is the day number of the problem. This will create some starting code in the src/day01 directory as well as a test in the test directory.

To run a day's problems use the command

gleam run -m day01/solution

To run the unit tests for all the days run

gleam test

For some problems, setting the AOC_DEBUG environment variable outputs additional information.

  • Day 1: ⭐ ⭐ solution

  • Day 2: ⭐ ⭐ solution

  • Day 3: ⭐ ⭐ solution

  • Day 4: ⭐ ⭐ solution

  • Day 5: ⭐ ⭐ solution

  • Day 6: ⭐ ⭐ solution

  • Day 7: ⭐ ⭐ solution

  • Day 8: ⭐ ⭐ solution

    This was an interesting problem, and I ended up learning a few new things. If you define a circuit as the set of all connected junctions, then you can find the union of the sets to which the two junction boxes you are connecting belong in order to find the new connected circuit. The difficulty is finding an efficient way to look up a set given one element from the set. In my initial solution I created a dict which had junction boxes as the key and sets of junction boxes as the values. This meant changing the values of all the elements in the dictionary that belonged to a set when a new union was made. In the Gleam Discord the disjoint-set data structure came up as a way to do this more efficiently, so I decided to try it and created a simple disjoint-set library. Using the new structure, and making a few other changes, the second part of my solution is roughly 3 times faster.

  • Day 9: ⭐ solution

    I ran into an issue doing part 2. I think it is that I am only checking if the corners are inside the figure. It may be that the corners are inside, but there is a line going through one of the walls. I ran out of time this morning to work on this and will pick it up later.

  • Day 10: ⭐ solution

    I tried doing part 2 a naive way with some memoization, but it seems like I still need to work on it. Code was getting very convoluted anyway, not pretty like the first several days.

About

The most wonderful time of the year!

Topics

Resources

Stars

Watchers

Forks