AOC/2023/day11/src/part1.py
2023-12-11 08:49:13 +01:00

34 lines
655 B
Python

text: str = open("input.txt", "r").read()
_value: int = 0
lines = text.splitlines()
empty_lines: int = 0
cords: [(int, int)] = []
for y, line in enumerate(lines):
if "#" in line:
for _ in range(line.count("#")):
cords.append(y + empty_lines)
else:
empty_lines += 1
bozo: int = 0
empty_colums: int = 0
for x in range(len(lines[0])):
apagnan = 1
for y in range(len(lines)):
if lines[y][x] == "#":
apagnan = 0
cords[bozo] = (x + empty_colums, cords[bozo])
bozo += 1
if apagnan:
empty_colums += 1
while len(cords):
xa, ya = cords.pop()
print(xa, ya)
for xb, yb in cords:
_value += abs(xb - xa) + abs(yb - ya)
print(_value)