You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
639 B
27 lines
639 B
lines = []
|
|
for l in open("input.txt", 'r').read().splitlines():
|
|
p = l.split(" -> ")
|
|
q = []
|
|
q.append(p[0].split(","))
|
|
q.append(p[1].split(","))
|
|
lines.append([[int(q[0][0]),int(q[0][1])],[int(q[1][0]), int(q[1][1])]])
|
|
grid = [[0 for i in range(1000)] for j in range(1000)]
|
|
|
|
for l in lines:
|
|
if l[0][0] == l[1][0]:
|
|
if l[0][1] > l[1][1]:
|
|
l = (l[1],l[0])
|
|
for i in range(l[0][1], l[1][1]+1):
|
|
grid[l[0][0]][i] += 1
|
|
if l[0][1] == l[1][1]:
|
|
if l[0][0] > l[1][0]:
|
|
l = (l[1],l[0])
|
|
for i in range(l[0][0], l[1][0]+1):
|
|
grid[i][l[0][1]] += 1
|
|
|
|
overlaps=0
|
|
for m in grid:
|
|
for n in m:
|
|
if n > 1:
|
|
overlaps += 1
|
|
print(overlaps)
|
|
|