News
Hints Day 20 and 21; Announcements & Happy Holidays
Written on 21.12.2022 11:10 by Sven Rahmann
Dear all,
the snow is gone, so no White Christmas this year, but ever more AoC problems... At least you'll not be bored. To help you a little bit, here are some comments, but first some Announcements.
This week, the tutorials will take place regularly unless your tutor explicitly invites you to an online tutorial.
The next regular lecture is on January 3 at the usual time and place (zoom). We will discuss numpy (for efficiently storing array data of a fixed type) and numba (for just-in-time compiling parts of your program to speed it up, up to 100x in some cases). There will be no further exercises for the material in January, but several examples, and they should also help further with the AoC problems.
In January, you should finish you AoC problems to get >= 35 stars, but also revise what you have done earlier, maybe comment your code, re-write some of your earlier solutions to make them shorter or more elegant and prepare to talk about them and explain them during the exam.
Hints for Day 20 (Tuesday)
The solution is not very long or complicated, if you use the right data structure. Unfortunately, we did not discuss singly or doubly linked lists yet, but you may want to have a look at them: https://en.wikipedia.org/wiki/Linked_list . We will also talk about them in January. As you need to walk left and right, you may think you need a doubly linked list, but in fact, because it is circular, you can always walk right (just compute the number of steps correctly!) and get away with a singly linked list, which requires less coding (I did not try it, I used a doubly linked list, so no guarantees). Part 2 seems to take ridiculously long because of the huge shift sizes, but of course, there is a shortcut to figure out.
Hints for Day 21 (Wednesday, today)
Part 1 is a straightforward recursive problem. An relatively easy start to get for a day 21 problem. The second part, on the other hand, can be hard. You could try to implement your own little solver with limited capabilities, but enough to solve the problem. Or you can have a look at the sympy package. The latter needs less coding, but of course you need to figure out how the whole package works and how to turn the problem into something that sympy can solve. If you use external packages, make it very clear in a docstring at the top of your program that you do and why.
General hints
We will check some of your code in gitlab on OUR inputs (not yours!). So your code must parse the input file, not hard-code your input; otherwise it will not output the correct solution on our inputs. It can actually happen that your code is correct for your input but not in general (especially for day 19, where you might take shortcuts that are wrong in general, but worked for your input). If we find such a case, we will certainly ask you about that particular code, but of course, we will not (and cannot) take away the stars. Please ensure that we can just run (for example) python day19.py
after getting your file and that it reads day19.txt
. (In an earlier version, this mentioned input19.txt, but the input file for day 19 should be called day19.txt.)
Most repositories seem to be readable and identifiable now; a recent version of the star statistics has been uploaded to the Materials section; please see if your matriculation number appears in the list. If not, please read the instructions again (here in older news).
Happy holidays!