Commit graph

9 commits

Author SHA1 Message Date
ffc5088813 Improve aoc helper script 2024-12-12 13:53:43 +01:00
3170846595 Solve 2016:17 p1-2 "Two Steps Forward"
Generators baby.
2024-12-12 13:53:43 +01:00
63a7ccd0e2 Simplify scaffold code 2024-12-12 13:53:43 +01:00
cdd5f63be4 Solve 2016:16 p1-2 "Dragon Checksum" 2024-12-12 13:53:43 +01:00
623253ac9d Solve 2016:15 p1-2 "Timing is Everything"
Good TIME to be a Python programmer!
2024-12-12 13:53:43 +01:00
31bb5b7006 Solve 2016:14 p1-2 "One-Time Pad"
Lost 60 minutes due to misinterpreting this in p2:

> *whenever* you generate a hash

The code initially only did the 2016 stretching for
the triplet hash, not the quintet hash. By doing it
to both, pt 2 is solved.

Not sure the lru cache actually speeds anything up.
Many on the subreddit used the approach to generate
the quintet first and look backwards 1000 times
for a matching quintet (since quintets are more
rare than triplets), this will most likely speed
things up.

Also, this solution do not store the found keys.
Many other solutions do, I believe this is some
presumptions.
2024-12-12 13:53:43 +01:00
c113042e17 Solve 2016:11 p1-2 "Radioisotope Thermoelectric Generators"
Hard one, an infamous AoC puzzle according to
Reddit.

Apparently, this is a classic logic problem named
"Missionaries and cannibals", or "Jealous husbands".

Hard lessons:

- Always use set() for visited nodes during BFS.
- Always use collections.queue() to create to queue
  traversals for BFS.
- itertools permutations(), combinations() and
pairwise() may look similar, but they are not.
- Learned to use (?:chunk of text)? in regex.

Test data was achieved without bigger hazzles, but
to optimize code required a lot of Reddit browsing
and code reading from blogs. I have mentioned the
sources in a doc string.
2024-12-12 13:53:43 +01:00
b1b5cda1e3 Solve 2016:12 p1-2 "Leonardo's Monorail" 2024-12-12 13:53:43 +01:00
8d4af7e6e9 Solve 2016:13 p1-2 "A Maze of Twisty Little Cubicles"
BFS baby.
2024-12-12 13:53:43 +01:00