Exemplo n.º 1
0
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!')

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

    if move_number % 1000000 == 0:
        print(f'movin... {move_number}')

one = cups.get(1)
next_after_one = one.next.data
next_next_after_one = one.next.next.data
print('Next two cups: {}, {}'.format(next_after_one, next_next_after_one))
print('Part 2 Answer: {}'.format(next_after_one * next_next_after_one))