Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import time
- #Läs och rengör input
- def gen():
- grid = np.zeros((1000, 1000))
- vals = []
- with open("input.txt", "r") as input:
- for row in input.readlines():
- id, sep, start, size = row.split()
- x1, y1 = map(int, start[:-1].split(","))
- x2, y2 = map(int, size.split("x"))
- grid[x1:x1 + x2, y1:y1 + y2] += 1
- vals.append((id, (x1, y1), (x2, y2)))
- return grid, vals
- #Del 1
- def p1():
- grid, _ = gen()
- return (grid >= 2).sum()
- #Del 2
- def p2():
- grid, vals = gen()
- for id, (x1, y1), (x2, y2) in vals:
- if (grid[x1:x1 + x2, y1:y1 + y2] == 1).all():
- return id
- return None
- print(p1())
- print(p2())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement