aoc2021/7/b.py

25 lines
458 B
Python

with open("input.txt") as f:
all_crabs = [int(i) for i in f.read().strip().split(",")]
# all_crabs = [int(i) for i in "16,1,2,0,4,2,7,1,2,14".split(",")]
tries = []
for i in range(0, len(all_crabs)):
print(i)
moves = 0
for crab in all_crabs:
for c in range(1, abs(i - crab) + 1):
moves += c
tries.append((i, moves, ))
from pprint import pprint
tries.sort(key=lambda x: x[1], reverse=True)
pprint(tries)
# 12m