parent
1e87a2eb67
commit
6cd6caa420
3 changed files with 39 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) |
@ -0,0 +1,10 @@ |
||||
0,9 -> 5,9 |
||||
8,0 -> 0,8 |
||||
9,4 -> 3,4 |
||||
2,2 -> 2,1 |
||||
7,0 -> 7,4 |
||||
6,4 -> 2,0 |
||||
0,9 -> 2,9 |
||||
3,4 -> 1,4 |
||||
0,0 -> 8,8 |
||||
5,5 -> 8,2 |
Loading…
Reference in new issue