From 3c78737aecd7fccf8b1b3a6bf6adfed624544b98 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Sat, 26 Dec 2020 21:51:16 +0100 Subject: [PATCH] Complete day 15, part 1 --- 15/part1 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 15/part1 diff --git a/15/part1 b/15/part1 new file mode 100755 index 0000000..af3093b --- /dev/null +++ b/15/part1 @@ -0,0 +1,29 @@ +#!/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 + print(turn, num) + if turn >= 2020: + break +