aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2025/README.md36
1 files changed, 35 insertions, 1 deletions
diff --git a/2025/README.md b/2025/README.md
index dc87240..09d97c1 100644
--- a/2025/README.md
+++ b/2025/README.md
@@ -178,4 +178,38 @@ cases now.
178### Day 10: Factory 178### Day 10: Factory
179 179
180Phew, this was a hard one! 180Phew, this was a hard one!
181(More details coming soon, for now read the code and the comments) 181
182Part 1 was quite easy, I just try all combinations of button presses
183until one works. It still took me relatively long to type it out.
184
185Part 2 was hard. Maybe not as hard to come up with as Day 9, but it
186took me much longer to thing through and type the complete solution.
187It is the first problem of this year's edition that I cannot fully solve
188before going to work (problems come out at 6AM in my time zone).
189
190So at first I tried to implement a recursive solution with memoization
191(using Python's
192[`functools.cache`](https://docs.python.org/3/library/functools.html#functools.cache)), but that was too slow. You can still check it out
193in `10/b-recursive-slow.py`.
194
195Then I thought about using linear algebra. I also had other ideas,
196but one particular sentence in the problem's statement strongly hints
197at that: *"You have to push each button an integer number of times;
198there's no such thing as "0.5 presses" (nor can you push a button a
199negative number of times)."*
200
201Like, come on. This sentence makes no sense at all in the context
202of this problem. It is only useful if you are already thinking about
203using linear algebra to solve this, but somehow along your reasoning
204you forgot that you are working with non-negative integers?
205
206Anyway, I briefly tried using [numpy's linear system
207solver](https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html),
208but it would have been more complicated to figure out how to use this
209library in my case than to re-implement the necessary algorithms from
210scratch. And so I rolled up my sleeves and started coding... after all,
211it is not the first time I have to home-cook some linear algebra for an
212AoC problem (see `../2023/24/24b.c`).
213
214This time I left some comments in the code, so check out `10/b.py` if
215you want to know the details.

Generated with cgit - Back to sebastiano.tronto.net