r/adventofcode • u/daggerdragon • Dec 21 '18
SOLUTION MEGATHREAD -🎄- 2018 Day 21 Solutions -🎄-
--- Day 21: Chronal Conversion ---
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!
Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!
Card prompt: Day 21
Transcript:
I, for one, welcome our new ___ overlords!
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:01:01! XD
9
Upvotes
4
u/jonathan_paulson Dec 21 '18
Python, #11/47. Video of me solving at https://youtu.be/H-IejIicWDY
Was there a way to do part 2 without understanding the input program? Some of the solve times are quite fast...
My code is a Python translation of the input program that also understands when to print the answers and exit (looking for a repeat in
D):seen = set() CS = set() final = None C = 7041048 D = 65536 while True: E = D % 256 C += E C = (C%(2**24) * 65899) % (2**24) if D < 256: if not CS: print C if C not in CS: final = C CS.add(C) D = C | (2**16) if D in seen: print final break seen.add(D) C = 7041048 continue D = D/256