2017 progress.
This commit is contained in:
27
2017/d6.py
Normal file
27
2017/d6.py
Normal 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)])
|
||||
Reference in New Issue
Block a user