Day 15 - Advent of Code 2016
Working solutions for the day 15 puzzles.
Part One
""" day_15_01.py """
# usage: python3 day_15_01.py < input
discs = []
while True:
try:
atoms = input().split()
total = int(atoms[3])
position = int(atoms[11][:-1])
except EOFError:
break
discs.append((position, total))
t = 0
check = [False]
while not all(check):
t += 1
check = []
for i, (position, total) in enumerate(discs):
discs[i] = ((position + 1) % total, total)
check.append(total - (position + 1) == (i + 1) % total)
print(t)
Part Two
""" day_15_02.py """
# usage: python3 day_15_02.py < input
discs = []
while True:
try:
atoms = input().split()
total = int(atoms[3])
position = int(atoms[11][:-1])
except EOFError:
break
discs.append((position, total))
discs.append((0, 11))
t = 0
check = [False]
while not all(check):
t += 1
check = []
for i, (position, total) in enumerate(discs):
discs[i] = ((position + 1) % total, total)
check.append(total - (position + 1) == (i + 1) % total)
print(t)