-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
48 lines (45 loc) · 1.39 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np
import helper
grid = np.array([
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 8, 0, 0, 8, 8, 0, 0],
[0, 0, 0, 8, 0, 0, 0, 8, 0, 0],
[0, 0, 0, 8, 8, 0, 8, 8, 0, 0],
[0, 0, 0, 8, 8, 8, 8, 8, 0, 0],
[0, 0, 0, 8, 8, 8, 8, 8, 0, 0],
[0, 0, 0, 0, 8, 8, 8, 0, 0, 0],
[8, 8, 8, 0, 8, 8, 8, 0, 8, 8],
[8, 8, 0, 0, 8, 8, 8, 0, 0, 8],
[8, 8, 8, 0, 8, 8, 8, 0, 8, 8],
[8, 8, 0, 8, 8, 8, 8, 0, 0, 8],
])
holes = 0
rowsWithHoles = 0
holeDepth = 0
reachableIdentifier = helper.DyeingAlgorithm(grid)
for i in range(len(grid)):
rowHasHole = False
for j in range(len(grid[0])):
if reachableIdentifier[i][j] == 1:
if grid[i][j] == 0:
rowHasHole = True
holes += 1
for k in range(len(grid) - 1, -1, -1):
if reachableIdentifier[k][j] == 0:
holeDepth += (i - k - 1)
break
rowsWithHoles += rowHasHole
print(helper.NormalizeGrid(grid))
print(reachableIdentifier)
print(holes)
print(rowsWithHoles)
print(holeDepth)