Day 13 (glamorized)

This commit is contained in:
Sebastian Seedorf
2021-12-13 09:58:19 +01:00
parent 8f9365821f
commit c217d7b24a
2 changed files with 9 additions and 13 deletions

View File

@@ -2,16 +2,15 @@
lines = (x.strip() for x in open("input.txt"))
points = set()
# 1311,895
for line in lines:
if line.startswith("fold along x="):
mark = int(line[13:])
points = set((x if mark > x else 2*mark-x, y) for x, y in points if mark != 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="):
mark = int(line[13:])
points = set((x, y if mark > y else 2*mark-y) for x, y in points if mark != 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(",")))