r/adventofcode • • Dec 22 '18

SOLUTION MEGATHREAD -🎄- 2018 Day 22 Solutions -🎄-

--- Day 22: Mode Maze ---


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 22

Transcript:

Upping the Ante challenge: complete today's puzzles using ___.


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 01:02:36!

12 Upvotes

102 comments sorted by

View all comments

Show parent comment

1

u/abnew123 Dec 22 '18

well, each swap is 7 added right? since any combination of 2 types can be done without swapping, I believe the max swaps without going out of bounds is (N+M) /2. So, in total D<4.5 (N+M). Since each K takes 2K, 2K < 3.5(N+M), so K< 1.75(N+M)? I don't know if that's tighter or less tight than your bound. I just used 2 instead of 1.75 in my solution.

1

u/asger_blahimmel Dec 22 '18

I'm not sure if such a map exists, but for the sake of argument consider a map like:

M|=.|=.|=
|=.|=.|=.
=.|=.|=.|
.|=.|=.|=
|=.|=.|=T

At each coordinate you have to switch tools (except the very last one, to which you already arrive with the torch in your hand), so the max swaps is N+M-1 and not (N+M)/2, isn't it?

1

u/abnew123 Dec 22 '18

Yeah, you're right. I completely forgot the tool also has to be valid for the square you are on too. However, looking at that example, going outside the region would at most save max(M,N) swaps right? Since min(M,N) swaps are required just to get to the boundary.