-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13-2.py
More file actions
36 lines (31 loc) · 883 Bytes
/
13-2.py
File metadata and controls
36 lines (31 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import numpy as np
from pprint import pprint
N = 1500
paper = np.zeros((N, N), dtype=bool)
def to_char(b):
if b:
return "#"
return " " # Use space instead of dot as it is easier to read
line = input()
while line:
dot_y, dot_x = line.split(",")
paper[int(dot_x), int(dot_y)] = True
line = input()
try:
x, y = N, N
while True:
text, number = input().split("=")
number = int(number)
if text[-1] == "y": # Fold along y
x = number
for i in range(number):
j = 2 * number - i
paper[i, :] |= paper[j, :]
else: # Fold along x
y = number
for i in range(number):
j = 2 * number - i
paper[:, i] |= paper[:, j]
except EOFError:
for line in paper[:x, :y]:
print("".join(to_char(b) for b in line))