From f9fe016835ef97a31ad73db42ffa17a3a36bb722 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sat, 26 Dec 2020 22:07:03 +0100 Subject: [PATCH] Complete day 15, part 2 --- 15/part2 | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 15/part2 diff --git a/15/part2 b/15/part2 new file mode 100755 index 0000000..65dc2a7 --- /dev/null +++ b/15/part2 @@ -0,0 +1,30 @@ +#!/usr/bin/python3 + +import sys +import time +from pprint import pprint + +turn = 0 +num = None +last_turn = {} + +for a in sys.argv[1:]: + last_turn[num] = turn + turn += 1 + num = int(a) + +pprint(last_turn) + +while True: + if num in last_turn: + new_num = turn - last_turn[num] + else: + new_num = 0 + last_turn[num] = turn + num = new_num + turn += 1 + if turn % 100000 == 0: + print(turn, num) + if turn == 30000000: + break +