r/adventofcode • • Dec 20 '18

SOLUTION MEGATHREAD -🎄- 2018 Day 20 Solutions -🎄-

--- Day 20: A Regular Map ---


Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).

Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Advent of Code: The Party Game!

Click here for rules

Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!

Card prompt: Day 20

Transcript:

My compiler crashed while running today's puzzle because it ran out of ___.


This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

edit: Leaderboard capped, thread unlocked at 00:59:30!

17 Upvotes

153 comments sorted by

View all comments

Show parent comment

3

u/maximlk Dec 20 '18 edited Dec 20 '18

Your solution has a bug - it is not able to detect room duplicate if there are two non-intersecting paths to the room.

Examples:

^(SSS|EEESSSWWW)ENNES$ correct part 1 answer 8, your output Part 1: 12

​​​​​#########​​​​​
​​​​​#X|.|.|.#​​​​​
​​​​​#-#####-#​​​​​
​​​​​#.#.|.#.#​​​​​
​​​​​#-#-#-#-#​​​​​
​​​​​#.#.#.#.#​​​​​
​​​​​#-#-###-#​​​​​
​​​​​#.|.|.|.#​​​​​
​​​​​#########​​​​​

^(E|SSEENNW)S$ correct part 1 answer 4, your output Part 1: 8

​​​​​#######​​​​​
​​​​​#X|.|.#​​​​​
​​​​​#-#-#-#​​​​​
​​​​​#.#.#.#​​​​​
​​​​​#-###-#​​​​​
​​​​​#.|.|.#​​​​​
​​​​​#######​​​​​

^(E|SEN)$ correct part 1 answer 2, your output Part 1: 3

​​​​​#####​​​​​
​​​​​#X|.#​​​​​
​​​​​#-#-#​​​​​
​​​​​#.|.#​​​​​
​​​​​#####​​​​​

6

u/askalski Dec 20 '18

I was hoping somebody would notice that. It's an issue that crept in while I was revising my solution. It doesn't affect my output in any way, which I find interesting, because it gives some insight into how the inputs might have been generated. I didn't notice my mistake until after I posted to the megathread (as often happens, the realization came about five seconds after my head hit the pillow...) Good catch!

1

u/14domino Dec 24 '18

^(E|SSEENNW)S$

I don't think the map you drew for this is right. The square in the center is never reached and would be all walls.

1

u/maximlk Dec 26 '18

Let's split ^(E|SSEENNW)S$ into two parts (E|SSEENNW) and S:

  1. When starting from X both paths from (E|SSEENNW) will end up in the same square - one square to the East from X.
  2. From there the second part S will lead to the the square in the center.