2017 progress.

This commit is contained in:
2024-05-18 07:38:03 -04:00
parent 3c290b8da3
commit 78b1981ddf
6 changed files with 146 additions and 1 deletions

27
2017/d6.py Normal file
View File

@@ -0,0 +1,27 @@
data = open(0).read().strip()
# data = "0 2 7 0"
banks = list(map(int, data.split()))
seen = dict()
seen[tuple(banks)] = 0
c = 0
while True:
c += 1
max_index = banks.index(max(banks))
blocks = banks[max_index]
banks[max_index] = 0
index = max_index
while blocks > 0:
index = (index + 1) % len(banks)
if index == max_index:
continue
banks[index] += 1
blocks -= 1
if tuple(banks) in seen:
break
seen[tuple(banks)] = c
print(c)
print(c - seen[tuple(banks)])