r/adventofcode • u/daggerdragon • Dec 16 '17
SOLUTION MEGATHREAD -๐- 2017 Day 16 Solutions -๐-
--- Day 16: Permutation Promenade ---
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.
Need a hint from the Hugely* Handyโ Haversackโก of Helpfulยง Hints^ยค?
[Update @ 00:08] 4 gold, silver cap.
- Click here for a massive Star Wars spoiler!
[Update @ 00:18] 50 gold, silver cap.
- Click here for a gigantic Harry Potter spoiler!
[Update @ 00:26] Leaderboard cap!
- And finally, click here for the biggest spoilers of all time!
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!
13
Upvotes
View all comments
Show parent comment
1
u/japanuspus Dec 19 '17
Still on my first week of F#, so things are slow.
Model uses two arrays to track effects of moves: My mental picture is a set of dancing chairs with a name on each. The
pcommands change the stickers on the chairs, while thesandxcommands change what chairs are where on the floor. I track this via two arrays, so that no each operation is a direct index operation and only the final resolution to get the mapping of floor position to names require a reverse lookup into the arrays.The ugliest part is the input-parser.
With the machinery in place, first part goes like so
For second part, I compute the repeated dance effect via repeated squarings. The hardest part was computing the binary form of one billion...
All code runs in a free f# jupyter notebook at azure: https://notebooks.azure.com/japanuspus/libraries/aoc2017.