3 min read

Advent of Code 2020 Day 20

Advent of Code 2020 Day 20

So, Day 20 was rough and maybe it was rough because I took shortcuts in the first part, to get that answer sooner, and that came to kind of mess with me later on. I will freely admit that today's puzzle was done half in about 2 hours late last night (11 pm is when the puzzle released) and half after I got a few hours of sleep, and even then I ended up spending close to 5 hours on my solution (and I'm sure there's still more optimizations to make to improve it later (and like others, I'm sure there's still more optimizations to make.

My Day 20 Personal Submission Stats

Part one had some fairly good optimizations that could take place. The general idea of part one was that you're given a set of tiles that are patterned, and the tiles connect (can be flipped or rotated) to each other based on the edge pattern. The problem was that part one only required you to get the product of the 4 corners, and because of that, I (along with most people doing this puzzle most likely) decided to not do any of the difficult puzzle piece placement because there was a shortcut. It still took me about an hour to get there because as I stated before, I forgot that it included both rotating AND flipping (flipping means having to reverse the matching strings). Once I made sure the example had 4 tiles with 2 matching edges, 4 with 3 matching edges and 1 with 4 matching edges, I could return the product of the 4 tiles with 2 matching edges for both the sample and my own problem statement.

Part two came about and on top of actually needing to join everything (for the pattern matching of the sea monster) I also decided after a few hours to simply call it quits and go to bed, realizing that this problem may take a long time, and "tomorrow" David (which was actually "today" David at the time) can deal with the mess. I did come with a renewed energy, realizing that if I take a more human approach to the problem, I can methodically solve the problem. So, I went from having the number of neighboring tiles to actually building out the lists of the neighboring tiles, that then gave me the ability to place the tiles from top-left to bottom right in a serial fashion. Once I was able to place all of the tiles, I then worried about rotation, then once all rotated properly, it was pretty simple to do the rest of the work to orient the full image properly and match for the sea dragon/sea monster.

I think Part 2 today was a nice challenge, something that would be fairly easy to do if you were doing all of this methodically yourself (i.e. had everything printed out where you could rotate and flip as needed) but these are the types of things that are easier to physically do than to program, because what's happening in these cases is more of a human thing, than a computer thing. I did a pretty good job documenting the code this time, so feel free to check it out. I'm sure I'll have some revisions after Christmas and after I take care of cleaning up and organizing my office to mount new monitors (see below)

New Monitors to mount over my Winter Break

If you want to join my Advent of Code leaderboard, feel free to join with the code: 699615-aae0e8af.

Enjoying these posts? Subscribe for more