-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday3puzzle2.py
36 lines (31 loc) · 885 Bytes
/
day3puzzle2.py
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
sheet = np.zeros((1000, 1000))
with open('fabric_claims.txt', 'r') as claims:
for claim in claims:
claim = claim.split()
x, y = claim[2][:-1].split(',')
x = int(x)
y = int(y)
w, h = claim[-1].split('x')
w = int(w)
h = int(h)
for i in range(w):
for j in range(h):
sheet[x+i, y+j] += 1
with open('fabric_claims.txt', 'r') as claims:
for claim in claims:
claim = claim.split()
cid = claim[0]
x, y = claim[2][:-1].split(',')
x = int(x)
y = int(y)
w, h = claim[-1].split('x')
w = int(w)
h = int(h)
overlap = False
for i in range(w):
for j in range(h):
if sheet[x+i, y+j] > 1:
overlap = True
if not overlap:
print(cid)