Exemplo n.º 1
0
for x in puzzle_input:
    cups.add(int(x))
min_cup = min(cups)
max_cup = max(cups)

move_number = 1
while move_number <= 100:
    cups = move(move_number, cups, min_cup, max_cup, False)
    move_number += 1

print('-- final --')
print('cups: {}'.format(cups))

# For final answer, rotate head until 1 is first.
while cups._head.data != 1:
    cups.rotate()

# Now the answer is the string minus the beginning 1.
print('Part 1 Answer: {}'.format(''.join([str(x) for x in cups if x != 1])))

print('Building Part 2 data set...')
cups = CircularList()
for x in puzzle_input:
    cups.add(int(x))
min_cup = min(cups)
max_cup = max(cups)
for x in range(max_cup+1, 1000000+1):
    cups.add(x)
max_cup = max(cups)
print('Done!')