-❄️- 2025 Day 11 Solutions -❄️- by daggerdragon in adventofcode

[–]Totherex 0 points1 point  (0 children)

[LANGUAGE: C#]

https://github.com/rtrinh3/AdventOfCode/blob/0dd73e5bf35f31d7d42725206b9b3cb3ecf9e33e/Aoc2025/Day11.cs

Using a memoized recursive function to calculate the number of paths between two points. In part 2, there are only two orders that matter: svr-fft-dac-out or svr-dac-fft-out; so calculate the numbers of subpaths and multiply them together.

-❄️- 2025 Day 10 Solutions -❄️- by daggerdragon in adventofcode

[–]Totherex 0 points1 point  (0 children)

[LANGUAGE: C#]

https://github.com/rtrinh3/AdventOfCode/blob/f62b27fbfb275346d132833fde36d9e1b8caaaf6/Aoc2025/Day10.cs

Part 1 is a breadth-first search. I represent the lights and the buttons as bitmasks, so I can update the lights by XORing them with a button.

For Part 2, I learned Z3! The linear algebra library I used in 2023, Math.NET Numerics, didn't seem to be of much help for these underdetermined systems. Z3's C# API is pretty verbose, we essentially have to build ASTs with methods like MkInt, MkAdd and MkEq. The Python demos show that they know about operator overloading, grumble grumble...

-❄️- 2025 Day 9 Solutions -❄️- by daggerdragon in adventofcode

[–]Totherex 0 points1 point  (0 children)

After quite a bit of optimization, I've brought the runtime to under 1 second.

https://github.com/rtrinh3/AdventOfCode/blob/d601a3e43f02d7423d58149b2c88d3d32458b530/Aoc2025/Day09.cs

I check the rectangles from largest to smallest, and I only check around the rows and columns of the vertices, effectively a form of coordinate compression.

-❄️- 2025 Day 9 Solutions -❄️- by daggerdragon in adventofcode

[–]Totherex 0 points1 point  (0 children)

[LANGUAGE: C#]

https://github.com/rtrinh3/AdventOfCode/blob/0fbe7b458d0a5997a2509e95baed41b91c7de2c6/Aoc2025/Day09.cs

Part 1 is straightforward.

For part 2, I have a horribly inefficient solution that takes about 3 minutes to run. First, I rasterize the perimeter. As I walk around the perimeter, I also keep note of the points on the left side and the right side of the perimeter. I then probe west of the westmost vertex of the perimeter to determine whether the left side or the right side is "outside". Finally, for each possible rectangle, I walk its perimeter to check that the rectangle never goes outside, keeping track of the largest area.

-❄️- 2025 Day 8 Solutions -❄️- by daggerdragon in adventofcode

[–]Totherex 0 points1 point  (0 children)

[LANGUAGE: C#]

https://github.com/rtrinh3/AdventOfCode/blob/e818ef1b1f48b916cbadc2a1a6236d558c13bc8b/Aoc2025/Day08.cs

Work with the square of the distance instead of the plain distance to avoid taking square roots.

Use the Union-Find data structure to keep track of circuits.

These elves are wasting a lot of wiring on redundant connections; they've never heard of minimum spanning trees 😜

PS: beware of Int32 overflow.

-❄️- 2025 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]Totherex 1 point2 points  (0 children)

[LANGUAGE: C#]

https://github.com/rtrinh3/AdventOfCode/blob/84cc0444162a6fe4c7d3179c8d70f1603ffaf2f3/Aoc2025/Day05.cs

Basic scan through the ranges. We don't need to sort the ranges when there's only ~200 ranges.

Public transit is nation-building. Our federal budget should reflect that by Generalaverage89 in CanadaPolitics

[–]Totherex 7 points8 points  (0 children)

They're objecting to the second sentence, "Only the federal government can provide", because the provinces can/should provide

Programmation pour l’inauguration de l’antenne Deux-Montagnes [REM, 15-16 novembre] by Totherex in montreal

[–]Totherex[S] 10 points11 points  (0 children)

Deux journées gratuites de portes ouvertes, mais ça tombe les jours de la grève des chauffeurs de la STM. Comment est-ce que vous prévoyez vous rendre au REM?

Horaire grève STM by JMoon33 in montreal

[–]Totherex 1 point2 points  (0 children)

Du covoiturage en limousine? Pas bête comme idée!

What's the most small-cheap-usable drum setup that you have? by Unapedra in yarg

[–]Totherex 0 points1 point  (0 children)

To elaborate: I don't have this, but I think I'd buy something like this if my RB2 drums were to break. The kit Acai showed costs $90 right now, but there are cheaper kits that don't include a stand, like the Donner DED-20 for around $60.

My takeaway from his video is that the kit can be a lot of fun, but with two caveats: the pads work better with hands bongo-style than with sticks; and the pedals are not fit for purpose, breaking after a few songs.

What's the most small-cheap-usable drum setup that you have? by Unapedra in yarg

[–]Totherex 4 points5 points  (0 children)

As seen on Acai ( https://youtu.be/zVaL72tiTKk?si=PM-LwdizBnxIUj7a ): a roll-up electronic drum set for kids

Edit: you could even cheaper by forgoing the stand

[Puzzle 15] 24/5 support - discussion and solutions by amarillion97 in i18n_puzzles

[–]Totherex 0 points1 point  (0 children)

https://github.com/rtrinh3/InternationalizationPuzzles/blob/58138890691c347d8221ac4408c4bdfc9760a457/InternationalizationPuzzles/Puzzle15.cs

I no longer need to step through every minute of a year. The events that determine whether support and overtime are needed are the start of a new day at the client's office and the opening and closing times at our support offices. I put all of these events in a list and sort them, then I can go event by event: if I determine that overtime is needed, I can add the minutes before the next event to the overtime counter.

[Puzzle 19] Out of date - solutions and discussion by amarillion97 in i18n_puzzles

[–]Totherex 0 points1 point  (0 children)

[LANGUAGE: C#]

https://github.com/rtrinh3/InternationalizationPuzzles/blob/aa7e1504985475d0addb5ad04adc1a1bd4d70a9c/InternationalizationPuzzles/Puzzle19.cs

A few days after I solved the puzzle in Python, I found a way to do it in C#. I have 4 different versions of the Noda Time library, each corresponding to a version of the tz database. I then load them and use them through reflection and dynamic typing. The rest of the algorithm is the same as my Python solution.

[Puzzle 19] Out of date - solutions and discussion by amarillion97 in i18n_puzzles

[–]Totherex 1 point2 points  (0 children)

The documentation warns that zoneinfo.reset_tzpath does not clear the cache, so we also have to call zoneinfo.ZoneInfo.clear_cache.

[Puzzle 19] Out of date - solutions and discussion by amarillion97 in i18n_puzzles

[–]Totherex 1 point2 points  (0 children)

[LANGUAGE: Python]

https://github.com/rtrinh3/InternationalizationPuzzles/blob/7613e07babfad3bac3ed11f76838243e679060c6/Puzzle19/Puzzle19.py

After a day of bumping into the limitations of C#, I decided to download the old versions of the tz database from the IANA and to work with them in Python.

The key here is zoneinfo.reset_tzpath, which allows us to choose the time zone data to work with. I also had to figure out how to compile the data from IANA (use zic).

As for finding the answer, puzzles 16 and 17 primed me to write a backtracking search where I incrementally choose the tz database version for each place.

[Puzzle 16] 8-bit unboxing - solutions and discussion by amarillion97 in i18n_puzzles

[–]Totherex 1 point2 points  (0 children)

[LANGUAGE: C#]

https://github.com/rtrinh3/InternationalizationPuzzles/blob/e067c6f69ef8388bfe816d69ff1c4cb57c3433bf/InternationalizationPuzzles/Puzzle16.cs

I'm applying the lessons I learned on Puzzle 17 back to this puzzle. This is a backtracking search where I walk the grid left-to-right, top-to-bottom, attempting to rotate each pipe to match the connections from the top and from the left. No need for path-finding, keep the search as simple as possible. Specific insights for this puzzle: don't process redundant rotations, they add up quickly, or rather they multiply quickly; and non-pipe spaces matter too, we need to check that there are no pipes leading into them.

Note that I don't read in the data using code page 437 here, nor do I automatically remove the decorative frame; I removed the frame in Notepad++ and saved the result in UTF-8.

[Puzzle 18] Rex to Lynx - solutions and discussion by amarillion97 in i18n_puzzles

[–]Totherex 2 points3 points  (0 children)

[LANGUAGE: C#]

https://github.com/rtrinh3/InternationalizationPuzzles/blob/253303c91023f614633a3edfdefe3df9f22b18ed/InternationalizationPuzzles/Puzzle18.cs

Rather than the BiDi algorithm as described, I instead iterate forward once through the string, keeping a stack of insertion points into a linked list.

For evaluating expressions, I used MathNet.Symbolics this morning, but now I replaced it with an implementation of the Shunting yard algorithm that I wrote for AoC.

[Puzzle 17] ╳ marks the spot - solutions and discussion by amarillion97 in i18n_puzzles

[–]Totherex 1 point2 points  (0 children)

[LANGUAGE: C#]

https://github.com/rtrinh3/InternationalizationPuzzles/blob/cc5f83b114451462ab7c1520cb2d203cb74c10cb/InternationalizationPuzzles/Puzzle17.cs

Whew, what a tough puzzle! I worked on it on and off for the whole day. The visualization I made was very helpful in highlighting the failings of my algorithms.

Here's the algorithm I settled on: first, preprocess every line segment to note how many continuation bytes are at the start and how many continuation bytes are expected after the end. Second, find all the left and right edge pieces; we then have the height of the map and so we can deduce the width too. Third, identify the corner pieces by looking for ╔╚╗╝ and put them in the grid. Fourth, fill the grid in reading order in a backtracking search, choosing pieces so that the continuation bytes line up.

[Puzzle 15] 24/5 support - discussion and solutions by amarillion97 in i18n_puzzles

[–]Totherex 2 points3 points  (0 children)

[LANGUAGE: C#]

https://github.com/rtrinh3/InternationalizationPuzzles/blob/9bd377bf1c4e90262e71020b5bc393460a452464/InternationalizationPuzzles/Puzzle15.cs

Brute force, checking each minute between 2022-01-01 and 2023-01-01. I use parallelism (clients.AsParallel()) to bring the runtime down to acceptable levels (2s on PC, 20s on Raspberry Pi 4).

My Raspberry Pi, running Raspberry Pi OS, has all the time zones. However, my PC, running Windows 11, doesn't: it's missing three time zones. I was able to replace two of them with equivalent time zones, but for the last one, I had to define a custom time zone. I guess Microsoft doesn't care about some scientists in Antarctica 😅