Language: Golang
This makes use of a template provided by https://github.com/nlowe for generating the CLI commands and inputs for each day.
This project was created with 1.21.
cd 2023
go mod download
go test ./...
go build
After building, the code can be run by typing the question name and part (a or b).
# Run Question 21 part 1
2023 21a
# Run all questions in sequence
2023 all
. | 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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Part 1 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Part 2 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Day 10: Constructing a closed path
Day 16: Following a set of branching lines (aka squiggles!)
Day 18: Constructing a closed path, again
This was the day I decided to teach myself enough regex to carry me through the rest of the season. Regexes are almost fun now.
Day 5 part 2 was the first question that took me a lot of time to find a solution I was happy with. I was able to brute force it in about 4 minutes when I first completed it, and then I rewrote it using interval programming. I'm sure there are a lot more efficient versions of the functions I wrote but I'm happy with this as my first exposure to the area.
The way the input of this problem is specifically set up to be much easier than one would expect if they were given an unknown input annoyed me a lot (a recurring theme for this year). Not content to settle for "just do LCM on the cycle lengths and it works just because", I added logic to properly check for cycles which encounter the "final" value at any point within the cycle (or multiple times).
Who needs difference methods for getting lists of numbers when you can use Lagrange polynomials instead :)
I'm not sure of how often I'll get use out of the even-odd method for determining if a point is contained in a contour but it I think it's pretty cool, and I was able to reuse it on day 18.
Dynamic Programming! The thing I've been avoiding forever. It's still pretty scary to me but I was able to come up with a general method for this question eventually.
Dijkstra, but you're able to jump between 1 and 3 nodes at once. This one was really tough to get my head around, but hopefully I can look back on this answer if anything like it is needed in the future.
Another question which relies on inspecting the input and realising the solution is to reverse engineer the machine to realise that it emulates a system with 4 12-bit registers that requires you to find the lowest common multiple of the values encoded in them. It really annoyed me that there was no indication that the input was special, and the alternative (to try and brute force a 48-bit state machine into a certain configuration) almost scared me away from this question.
Another case of "find the hidden property of the input that reduces this to some maths, and then do some maths". I documented some of my thought process as I progressed through this question in the comments in part 2, though all the assumptions I made in this question relied on me accidentally finding out the row 66 and column 66 of this question's input are empty.
My slowest question (part 2) runs in 6 seconds. The longest path problem is interesting but I don't see any obvious ways of optimising it except for maybe adding some caching.
This one went really, really heavy on the linear algebra, which I wasn't expecting. I had to import a package for this because I don't see any way of solving this without symbolic programming. On the plus side, I guess I know symbolic programming now, so no system of equations can ever stop me.
Day25s are usually easy but today was definitely an exception. Finding the right package to import was a huge pain but after that it was alright. This is the second day in a row where there would have been a very well known python package to import, but to complete it in Go I had to do a fair amount of searching, implementing, running into bugs, attempts at bug fixing before resigning and finding a new package, and reimplementing.
Language: Python (Jupyter Notebook)
. | 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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Part 1 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Part 2 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
These were generated with pyplot.imshow and pyplot.scatter
Day 14: The Falling Sand question
Day 17: The Tetris-like question
Day 22: Simulating Paths around a Cube
Day 23: The Diffusion question
Language: Python (Jupyter Notebook)
. | 1 | 2 | 3 | 4 |
---|---|---|---|---|
Part 1 | ✔️ | ✔️ | ✔️ | ✔️ |
Part 2 | ✔️ | ✔️ | ✔️ | ✔️ |