2018/Day3/Day3.py

16 lines
392 B
Python
Raw Normal View History

2018-12-05 13:14:47 +00:00
import numpy
import re
RE = re.compile(r"#(\d+) @ (\d+),(\d+): (\d+)x(\d+)")
with open("Day3.in", "r") as f:
ROWS = [[int(i) for i in RE.match(line).groups()] for line in f]
FABRIC = numpy.zeros((1000, 1000), dtype=numpy.uint8)
for _, x, y, w, h in ROWS:
FABRIC[x:x+w, y:y+h] += 1
for i, x, y, w, h in ROWS:
if (FABRIC[x:x+w, y:y+h] == 1).all():
print(i)
break