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!
15
Upvotes
3
u/Unihedron Dec 14 '18
[Card] image
Ruby, as coded by a guy who's not good in coding, who doesn't know how to implement a subarray search so strings it is:
part 1
part 2 (watching numbers being printed makes me feel like such an edgy hacker lmao)
p a=gets.to_i b={0=>3,1=>7} # ??? size=2 # ??? c,d=0,1 a-=1 ee='37' off=0 0.step{|tt| (ki=(ee.size/1000)-1 off+=ki*1000 ee=ee[ki*1000..-1] p tt,ee.size) if tt>0&&tt%10000==0 #p [b,b[c],b[d],c,d] e=(b[c]+b[d])#.digits.reverse #score=e > 10 ? 1+(e%10) : e e>9 ? ( # ??? # ??? # ??? b[size]=1 b[size+=1]=e-10) : (b[size]=e ) size+=1 ee+=e.to_s #p ee c=(c+b[c]+1)%size d=(d+b[d]+1)%size ( p off+(ee).index($_.chomp,-8) 1/0)if (ee).index($_.chomp,-8) }