Advent of Code 2020 - BaseA Style (Day 20)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Discussion thread for day 20 of the Advent of Code : https://adventofcode.com/2020/day/20
- Labels:
- Advent of Code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I really enjoyed Part 1 today. Part 2 is going to take a little longer though..... 🐍
Part 1 solution:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Like @Steph_Maddrell solved part 1 quickly. Part 2 I can get sample to work but something in my vast workflow doesn't work for it....
As it stands...
- Works out all the joins between tiles
- Works out all 8 versions of each tile
- Builds the grid layout (correct for sample at least)
- Creates the big jigsaw puzzle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
That was a slog (not winning tool golf...) to get a solution out - Part 2 below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Finally!
It's not pretty, but works (with some caveats)...
I spent way more time than I should have in this. Anything that involves having some type of "spatial vision" or rotating things in my mind I'm clueless.
My thought process on this one:
Pick one tile, get the matching tile, then go across and get the next tile and so on. I was trying to keep track of thinks like...
If tile A is not flipped, and the edge at Row_01 is matching tile B, not flipped, at Row_10, then tile B does not need to be rotated.
If tile A is not flipped, and the edge at Row_01 is matching tile B, flipped, at Col_01, then tile B needs to be flipped and rotated 3 times (or -1, but I sticked to +ve).
But I was doing something wrong (don't know what yet) and, although the array with the positions was correct, the orientation wasn't, so it was failing when building the big puzzle.
I eventually decided to stop sinking more time debugging that and chose to use the array with the positions to grow the board once more. This time, starting wtih one corner, then getting the adjacent tile with no prior information, get all the possible rotations and choose the rotation that fits. This makes it rather slow (~ 1min), but still faster than debugging the whole thing.
In order to find the seamonsters...
I took one seamonster (length 20), rotated it and flipped it to all possible orientations, chose one "#" at random and decided that was the "origin" of the seamonster. Then calculated offset in rows/columns for all the remaining parts of the seamonster.
I then evaluated whether each '#' in the map was a potential origin for a seamonster (that is, all the corresponding offseted rows and columns contain a # as well).
The only thing is... there's still something not quite completely working, meaning that it DOES matter which corner you start building from (in other words, I needed to run it a couple of times to make sure that seamonsters were found!
I also built more macros than I care...😅
