|
|
@ -6,22 +6,29 @@ for l in open("input.txt", 'r').read().splitlines(): |
|
|
|
q.append(p[1].split(",")) |
|
|
|
q.append(p[1].split(",")) |
|
|
|
lines.append([[int(q[0][0]),int(q[0][1])],[int(q[1][0]), int(q[1][1])]]) |
|
|
|
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)] |
|
|
|
grid = [[0 for i in range(1000)] for j in range(1000)] |
|
|
|
|
|
|
|
overlaps = 0 |
|
|
|
|
|
|
|
|
|
|
|
for l in lines: |
|
|
|
for l in lines: |
|
|
|
if l[0][0] == l[1][0]: |
|
|
|
xDir = 0 |
|
|
|
if l[0][1] > l[1][1]: |
|
|
|
yDir = 0 |
|
|
|
l = (l[1],l[0]) |
|
|
|
if l[0][0] > l[1][0]: |
|
|
|
for i in range(l[0][1], l[1][1]+1): |
|
|
|
xDir = -1 |
|
|
|
|
|
|
|
if l[0][0] < l[1][0]: |
|
|
|
|
|
|
|
xDir = 1 |
|
|
|
|
|
|
|
if l[0][1] > l[1][1]: |
|
|
|
|
|
|
|
yDir = -1 |
|
|
|
|
|
|
|
if l[0][1] < l[1][1]: |
|
|
|
|
|
|
|
yDir = 1 |
|
|
|
|
|
|
|
if xDir == 0: |
|
|
|
|
|
|
|
for i in range(l[0][1],l[1][1]+yDir,yDir): |
|
|
|
grid[l[0][0]][i] += 1 |
|
|
|
grid[l[0][0]][i] += 1 |
|
|
|
if l[0][1] == l[1][1]: |
|
|
|
if grid[l[0][0]][i] == 2: |
|
|
|
if l[0][0] > l[1][0]: |
|
|
|
overlaps += 1 |
|
|
|
l = (l[1],l[0]) |
|
|
|
if yDir == 0: |
|
|
|
for i in range(l[0][0], l[1][0]+1): |
|
|
|
for i in range(l[0][0],l[1][0]+xDir,xDir): |
|
|
|
grid[i][l[0][1]] += 1 |
|
|
|
grid[i][l[0][1]] += 1 |
|
|
|
|
|
|
|
if grid[i][l[0][1]] == 2: |
|
|
|
|
|
|
|
overlaps += 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
overlaps=0 |
|
|
|
|
|
|
|
for m in grid: |
|
|
|
|
|
|
|
for n in m: |
|
|
|
|
|
|
|
if n > 1: |
|
|
|
|
|
|
|
overlaps += 1 |
|
|
|
|
|
|
|
print(overlaps) |
|
|
|
print(overlaps) |
|
|
|