18 lines
647 B
Python
18 lines
647 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)
|
|
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)
|
|
elif len(line) > 0:
|
|
points.add(tuple(int(num) for num in line.split(",")))
|
|
|
|
max_x, max_y = tuple(map(max, zip(*points)))
|
|
print('\n'.join(''.join('#' if (x, y) in points else ' ' for x in range(max_x+1)) for y in range(max_y+1)))
|