Skip to content

Commit b32069d

Browse files
committed
wrote a couple words about it in the README
1 parent 8d2effd commit b32069d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,17 @@ information.
4343
- [Day 6](https://adventofcode.com/2025/day/6): [⭐ ⭐ solution](src/day06/solution.gleam)
4444
- [Day 7](https://adventofcode.com/2025/day/7): [⭐ ⭐ solution](src/day07/solution.gleam)
4545
- [Day 8](https://adventofcode.com/2025/day/8): [⭐ ⭐ solution](src/day08/solution.gleam)
46+
47+
This was an interesting problem, and I ended up learning a few new things. If
48+
you define a circuit as the set of all connected junctions, then you can find
49+
the union of the sets to which the two junction boxes you are connecting belong
50+
in order to find the new connected circuit. The difficulty is finding an
51+
efficient way to look up a set given one element from the set.
52+
In my [initial solution](https://github.com/devries/advent_of_code_2025/blob/b4ecead2fd971f0fec5223da3679160b599e851e/src/day08/solution.gleam) I created a dict which had junction boxes as the key
53+
and sets of junction boxes as the values. This meant changing the values of
54+
all the elements in the dictionary that belonged to a set when a new union
55+
was made. In the Gleam Discord the [disjoint-set data structure](https://en.wikipedia.org/wiki/Disjoint-set_data_structure)
56+
came up as a way to do this more efficiently, so I decided to try it and
57+
created a simple [disjoint-set library](src/internal/disjoint_set.gleam).
58+
Using the new structure, and making a few other changes, the second part of
59+
my [solution](src/day08/solution.gleam) is roughly 3 times faster.

0 commit comments

Comments
 (0)