2 min read

Advent of Code 2020 Day 11

I think the most frustrating part was that the example input data was processing and counting properly, but I was never able to get my input to work properly
Advent of Code 2020 Day 11

Today's puzzle was rough for me, and I still really don't know why it was so rough as the solution I had worked on for nearly an hour ended up being scrapped in favor of a WORKING solution. For the first time in Advent of Code, I was told to check the subreddit because I had submitted 5 incorrect values for part 1 (luckily, I had work meetings to attend to and actual work to do, so I took a break and decided to attack the problem fresh after my meetings during waiting times.

I initially tried to return a 2-D character array (char[][]) from my readfile method, but really, I found that a 2-D character array just somehow caused problems when it came to the final output, but ONLY with my puzzle input.  I spent time converting from a 2-D character array to a 1-D character array ( char[] ) but ended up having the same dang problem as I had with the 2-D character array. Because this was me about 90 minutes into attempting a solution and 3 hours into my morning, I said screw it and when with double-indexing a list of Strings (List<String>) with the row being the list index and column being the string's character index. This simplified printing for debugging as well as so much of the counting the final number of occupied seats. I think the most frustrating part was that the example input data was processing and counting properly, but I was never able to get my input to work properly, and specifically it was NOT counting certain characters (which I couldn't fix consistently).  

Once I made the change the hardest part was updating logic for part two which rather than looking at immediate cells within a 1-block vicinity of the current seat selection location, to the first seat in view of the seat in question for each of the 8 directions. That was just a different function for checking neighbors and was pretty easy to implement (assuming you didn't misread it as having the closest seat in the direction being any seat in the direction).

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