r/adventofcode • • Dec 21 '16

SOLUTION MEGATHREAD --- 2016 Day 21 Solutions ---

--- Day 21: Scrambled Letters and Hash ---

Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/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".


HOGSWATCH IS MANDATORY [?]

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!

4 Upvotes

83 comments sorted by

View all comments

Show parent comment

7

u/daniel-sd Dec 21 '16 edited Dec 21 '16

For size 8 this is true. But for the sample size (5), rotate around letter is not always reversible.

Take both 'acbde' and 'acdeb' and rotate based on position of b

01234
acbde

rotation = 2 + 1 + 0 = 3 result = 'bdeac'

acdeb
01234

rotation = 4 + 1 + 1 = 6 result = 'bdeac'

Unfortunately practicing with the sample input was quite confusing for this one.

2

u/BumpitySnook Dec 21 '16

Your puzzle input wasn't abcde, though. Topaz controls the inputs and the scrambling recipe.

2

u/topaz2078 (AoC creator) Dec 21 '16

For the second part, you can use the example generator you wrote in part 1. Furthermore, your input is the process, not the string - the string you're working on is the same for everyone.

1

u/bildzeitung Dec 21 '16

That's the gotcha -- size 8 is key to making that rule work. Eric's mapping function is unique over that string length.

1

u/eregontp Dec 21 '16

And indeed, for the example output (decab), there are two valid inputs: abcde and deabc.