parent
12d8cddddd
commit
215c6c6f93
2 changed files with 29 additions and 8 deletions
@ -0,0 +1,29 @@ |
||||
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)] |
||||
print(lines) |
||||
|
||||
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: |
||||
print(m) |
||||
for n in m: |
||||
if n > 1: |
||||
overlaps += 1 |
||||
print(overlaps) |
Loading…
Reference in new issue