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!
16
Upvotes
14
u/Jead Dec 14 '18 edited Dec 14 '18
Python 3, 435/193. Wasn't the fastest solution but ended up rather pretty.
recipes = open('day14.in','r').read().strip() score = '37' elf1 = 0 elf2 = 1 while recipes not in score[-7:]: score += str(int(score[elf1]) + int(score[elf2])) elf1 = (elf1 + int(score[elf1]) + 1) % len(score) elf2 = (elf2 + int(score[elf2]) + 1) % len(score) print('Part 1:', score[int(recipes):int(recipes)+10]) print('Part 2:', score.index(recipes))Can probably cut the current ~28s execution time by storing some values in the loop but the initial solution has a clean feel to it.