Files
python-aoc-2021/day13/part1.py
Sebastian Seedorf c217d7b24a Day 13 (glamorized)
2021-12-13 09:58:19 +01:00

19 lines
541 B
Python

#!/usr/bin/env python3
lines = (x.strip() for x in open("input.txt"))
points = set()
for line in lines:
if line.startswith("fold along x="):
fold = int(line[13:])
points = set((fold - abs(x-fold), y) for x, y in points if fold != x)
break
elif line.startswith("fold along y="):
fold = int(line[13:])
points = set((x, fold - abs(y-fold)) for x, y in points if fold != y)
break
elif len(line) > 0:
points.add(tuple(int(num) for num in line.split(",")))
print(len(points))