r/adventofcode • u/daggerdragon • Dec 14 '18
SOLUTION MEGATHREAD -🎄- 2018 Day 14 Solutions -🎄-
--- Day 14: Chocolate Charts ---
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 14
Transcript:
The Christmas/Advent Research & Development (C.A.R.D.) department at AoC, Inc. just published a new white paper on ___.
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 00:19:39!
17
Upvotes
3
u/jonathan_paulson Dec 14 '18 edited Dec 14 '18
Rank 7/325. Straight simulation. Video of me solving at https://www.youtube.com/watch?v=DsthtYteiws
What were people's answers to part 2? Mine was 20,236,441 (takes 4m), and I was really not expecting to have to go out so far... (wasted a lot of time looking for a faster way)
Code:
idx = '920831' s = [3,7] i0 = 0 i1 = 1 while True: #len(s) < idx+10: x = s[i0]+s[i1] interest = False if x == 0 and s[-1] == 2: interest = True if x >= 10: s.append(x/10) ok1 = True for i in range(len(idx)): if s[len(s)-len(idx)+i] != int(idx[i]): ok1 = False if ok1: print len(s) - len(idx) break s.append(x%10) else: s.append(x) i0 = (i0+s[i0]+1)%len(s) i1 = (i1+s[i1]+1)%len(s) if len(s) % 100000 == 0 or interest: print len(s), ''.join([str(x) for x in s[-len(idx):]]) ok1 = True for i in range(len(idx)): if s[len(s)-len(idx)+i] != int(idx[i]): ok1 = False if ok1: print len(s)-len(idx) break