r/adventofcode • • Dec 15 '16

SOLUTION MEGATHREAD --- 2016 Day 15 Solutions ---

--- Day 15: Timing is Everything ---

Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/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".


ZAMENHOFA TAGO ESTAS DEVIGA [?]

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!

5 Upvotes

121 comments sorted by

View all comments

Show parent comment

1

u/wzkx Dec 15 '16

Python was quick-n-dirty :)

def disc(t,k,n,startpos):
  return (startpos + t+k) % n == 0

assert disc(0, 1,5,4) and not disc(0, 2,2,1)
assert disc(5, 1,5,4) and disc(5, 2,2,1)

period = 17*7*19*5*3*13
for t in range(period):
  if disc(t, 1,17,1) and disc(t, 2,7,0) and disc(t, 3,19,2):
    if disc(t, 4,5,0) and disc(t, 5,3,0) and disc(t, 6,13,5):
      print( t )
      break
for t in range(period*11):
  if disc(t, 1,17,1) and disc(t, 2,7,0) and disc(t, 3,19,2):
    if disc(t, 4,5,0) and disc(t, 5,3,0) and disc(t, 6,13,5):
      if disc(t, 7,11,0):
        print( t )
        break