Advent Of Code 2020
No specific difficulty here
I made one mistake considering the valdity of a password. I only considered valid a password if the first check was True and the second one was False. This actually was validated by my test suite. I ended up with a wrong answer until I considered that another valid password could be mismatch on the first char and a match on the 2nd char.
- Wasted time because I failed to strip the input data :(
- Learned math.prod is only available in Python >= 3.8.
- Forgot to start parsing the input from line == down_step. data[down_step:0] instead of data[1:].
- Did not process the last passport because it was triggered by empty lines; first answer submission was short by 1 :(
- Tried to validate in one single if statement but couldn't debug.
- Broke down the vailidation tests in functions and unit tested them.
- Careful with range: 5 is not in range(0,5), it is in range(0,6).
- Improved my regexp skills - trying to capture groups but doing one single eval.
- Discovered a Python 3.8 feature: the walrus operator.
- I didn't realize directly the analogy with binary representation.
- Lost time trying to optimize with lambda or itertools.
- I still believe there must be an elegant set comparison that can compare "neighbor" seats.
- Need to find a better way to turn a str to a set of chars.
- Need to find a better way to initialize the set at first line of the group.
- I was wondering when recusrsion was going to start ?
- I shouldn't have assumed that 'gold' was a sufficient filter, 'shiny gold' was necessary since other types of gold were in the list of colors.
- Got bitten by empty lines at the end of the input file.
- Found an iterative way to get to the solution.
- Can't find a working recursive methodology :(
- I really wanted to improve the solution with a recursive function; I couldn't do it without deep copying the instruction set - which is probably not very efficient.
- Had to isolate pair in a function - wish I could do without the nested loop.
- too many off-by-one notations but works OK.
- Not elegant but not complex.
- Took a little while to figure out what the problem exactly was.
- Found out it only takes one unknown word (jolt) to make a problem much harder to grasp.
- I won't lie, I suffered ... but the satisfaction is proportional
- The testing of the puzzle use case was succesful but the solving of my input took hours to execute ...
- First you think it might take a few mins so my_lazy_and_confident_self is satisfied and just keeps an eye on the laptop So here is what my morning was like: Tested the part2 on the demo input, yeah, it works, run it with the real puzzle input ... hmmm, slower, but my_lazy_and_super_confident_self knows it is a matter of seconds or maybe even a few minutes...
- hmmm, still no output, let's go shower quickly,
- hmmm, still no ouput, let's wake up the wife,
- hmmm, still no output ... but 3% battery, run to find your laptop adapter,
- hmmm, still no output ... prepare breakfast for the kids
- hmmm, still no output ... take the kids to school ... but don't ask me to smile
- really, 2 hours and still no output ... maybe I could start working on a more efficient solution ...
- OK, time's up, it will be for tonight, let's get to work
- Oh, but wait, maybe ... I think ... if I did this ... it should ... let's try ... failed ... back to work for 10 min
- repeat until noon until it finally beautifully executed in 0.02sec
No particular comment, just couldn't find time to finish it in the morning.
Not fully satisfied with the direction shifting, there probably are more arithmetic ways to store waypoint and position coordinates.
- No particular difficulty
- I struggled hard - after multiple hours of not finding, I finally went to subreddit and used a solution for inspiration
- My solution actually worked but way too slow - I kept on bruteforcing with a constant increase (equal to max(buses).
- The main limitation was that I could not find how to increase the step.
- It turned out the right way is to compare 2 buses, then go to the next one by multiplying the increase by the value of the new bus.
- Another hint was to ignore the 'x' values by replacing them with 0 instead of keeping a dict with {offset: bus}.
- Interesting read about the Chinese Remainder Theory (https://en.wikipedia.org/wiki/Chinese_remainder_theorem).
- Refreshing reminder about bitwise operations.
- Nothing particular
- No particular difficulty
- Took ~1.5h to reach acceptable performance (execution time: 57sec).
- Interesting to notice that removing the counter (n 'if' statement) didn't reduce the execution speed.
- Trimmed 2 secs by using IndexErrors instead of testing index validity: ~55sec.
- Trimmed 2 secs by using Python 3.6.8 instead of Python 2.7.16.
- No impact when using a list instead of a dict to hold the numbers.
- ~39sec using a Memory class (day15b.py)
- As usual, pretty straightforward
- Quickly came to the solution but it took a serious amount of troubleshooting to understand a function was returning an int or None if not found; later on, this value was tested with "if value:". The side effect of this is that this became False if the function returned an index of 0 :(((
- On to day 17 now, personal record broken at this point ;)
- This one took some time to understand the best way to model it.
- Once P1 was done, this one was 8 mins.
- Completed on time but needs some refactoring before I share on GitHub
- Completed on time but needs some refactoring before I share on GitHub
- Spent more time on Strava than on AoC ;)
- Needs to catch up with the backlog
- [2020/12/27] Finally wrapped my head around this one. Got a hint from a friend, and gave up the elegant solution for the bruteforce "capped recursivity" - Not 100% satisfied but moving on ;)
- Got one silver star for day 20 on day 20
- Overlooked the instruction to remove the border from the tiles :((
- Haven't opened the problem on day 21.
- Hoping to get 19 and 20 finished by tomorrow (22) and get to 21 after tomorrow (23)
- From rank #40 to #rank 60 on Matt Goodrich's leaderboard
- [2020/12/28] Got inspiration from https://github.com/UnicycleBloke/aoc2020/blob/main/day21/day21.py abut the right use of sets.
- Not the cleanest way but good enough for today.
- Read extensively about the usage of argument splitting.
- First time usage of queue.Queue() - working as intended ;)
- No major issue
- Part 1 did not scale with larger numbers
- Changed the array structure to a chain of pointers (nostalgic flashback from CS classes in '96)
- Works sub 25 sec, which is OK
- First time using an hex grid, proud to have found a working solution without external inspiration.
- No major issue
- I failed to understand I needed to make the grid bigger (by 2 units in each direction) at every turn. I still think it was not clear in the problem description.
- Oooh, and we are the 19th of Feb, I missed the end of year deadline, procrastinated for 50 days now but I'm not giving up ;)
https://github.com/norvig/pytudes/blob/master/ipynb/Advent-2020.ipynb
- nice resources around Python optimisation
https://github.com/salt-die/Advent-of-Code/blob/master/2020/aoc_helper
- automated download of input
- automated submission
- automated template-based per-day directory creation