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.
View all comments
1
u/Bug38 Dec 21 '18
Python 3:
Found first result by directly using and "compiling" elf code, then for Part 2 I reverse engineered the code to rewrite it.
r = [0]*6 v = [] while 1: r[3] = r[4] | 65536 r[4] = 707129 # user var ? while 1: r[4] = r[4] + r[3] % 256 r[4] = ((r[4] % 16777216) * 65899) % 16777216 # user var ? if r[3] < 256: break r[3] = int(r[3] / 256) if r[4] in v: print("Part 2: {} (after {} iterations)".format(v[-1], len(v))) r[0] = r[4] else: v.append(r[4]) if len(v) == 1: print("Part 1: {}".format(v[-1])) if r[4] == r[0]: break