Day 15 (cleanup)
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
from collections import defaultdict
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
nums = defaultdict(list)
|
||||
TARGET = 2020
|
||||
|
||||
for line in lines:
|
||||
print(line)
|
||||
nums = defaultdict(list)
|
||||
turn = 0
|
||||
last_spoken = 0
|
||||
for starting in map(int, line.split(",")):
|
||||
@@ -16,10 +16,7 @@ for line in lines:
|
||||
last_spoken = starting
|
||||
for t in range(turn, TARGET):
|
||||
last = nums[last_spoken]
|
||||
if len(last) == 2:
|
||||
n = last[1] - last[0]
|
||||
else:
|
||||
n = 0
|
||||
n = last[1] - last[0] if len(last) == 2 else 0
|
||||
nums[n] = nums[n][-1:] + [t]
|
||||
last_spoken = n
|
||||
print("->", last_spoken)
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
from collections import defaultdict
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
nums = defaultdict(list)
|
||||
TARGET = 30000000
|
||||
|
||||
for line in lines:
|
||||
print(line)
|
||||
nums = defaultdict(list)
|
||||
turn = 0
|
||||
last_spoken = 0
|
||||
for starting in map(int, line.split(",")):
|
||||
@@ -16,10 +16,7 @@ for line in lines:
|
||||
last_spoken = starting
|
||||
for t in range(turn, TARGET):
|
||||
last = nums[last_spoken]
|
||||
if len(last) == 2:
|
||||
n = last[1] - last[0]
|
||||
else:
|
||||
n = 0
|
||||
n = last[1] - last[0] if len(last) == 2 else 0
|
||||
nums[n] = nums[n][-1:] + [t]
|
||||
last_spoken = n
|
||||
print("->", last_spoken)
|
||||
|
||||
Reference in New Issue
Block a user