added new array (6x6)
This commit is contained in:
parent
3b14cf087a
commit
5ee72d9383
1 changed files with 14 additions and 75 deletions
|
@ -1,83 +1,10 @@
|
||||||
__author__ = 'gaugendre'
|
__author__ = 'gaugendre'
|
||||||
|
|
||||||
from grid import Grid
|
from grid import Grid
|
||||||
# def solve(grid):
|
|
||||||
# y = 0
|
|
||||||
# while y < len(grid):
|
|
||||||
# x = 0
|
|
||||||
# while x < len(grid[0]):
|
|
||||||
# if grid[x][y] == ' ':
|
|
||||||
# v_prev_x, v_prev_y = prev_vert(x, y)
|
|
||||||
# v_p_prev_x, v_p_prev_y = prev_vert(v_prev_x, v_prev_y)
|
|
||||||
# v_next_x, v_next_y = next_vert(x, y, len(grid))
|
|
||||||
# v_n_next_x, v_n_next_y = next_vert(v_next_x, v_next_y,
|
|
||||||
# len(grid))
|
|
||||||
#
|
|
||||||
# h_prev_x, h_prev_y = prev_horiz(x, y)
|
|
||||||
# h_p_prev_x, h_p_prev_y = prev_horiz(h_prev_x, h_prev_y)
|
|
||||||
# h_next_x, h_next_y = next_horiz(x, y, len(grid[0]))
|
|
||||||
# h_n_next_x, h_n_next_y = next_horiz(h_next_x, h_next_y,
|
|
||||||
# len(grid[0]))
|
|
||||||
#
|
|
||||||
# be_blue = (exists(v_prev_x, v_prev_y) and
|
|
||||||
# exists(v_p_prev_x, v_p_prev_y) and
|
|
||||||
# grid[v_prev_x][v_prev_y] == 'R' and
|
|
||||||
# grid[v_p_prev_x][v_p_prev_y] == 'R') or \
|
|
||||||
# (exists(v_next_x, v_next_y) and
|
|
||||||
# exists(v_n_next_x, v_n_next_y) and
|
|
||||||
# grid[v_next_x][v_next_y] == 'R' and
|
|
||||||
# grid[v_n_next_x][v_n_next_y] == 'R') or \
|
|
||||||
# (exists(h_prev_x, h_prev_y) and
|
|
||||||
# exists(h_p_prev_x, h_p_prev_y) and
|
|
||||||
# grid[h_prev_x][h_prev_y] == 'R' and
|
|
||||||
# grid[h_p_prev_x][h_p_prev_y] == 'R') or \
|
|
||||||
# (exists(h_next_x, h_next_y) and
|
|
||||||
# exists(h_n_next_y, h_n_next_y) and
|
|
||||||
# grid[h_next_x][h_next_y] == 'R' and
|
|
||||||
# grid[h_n_next_x][h_n_next_y] == 'R') or \
|
|
||||||
# (exists(h_prev_x, h_prev_y) and
|
|
||||||
# exists(h_next_x, h_next_y) and
|
|
||||||
# grid[h_prev_x][h_prev_y] == 'R' and
|
|
||||||
# grid[h_next_x][h_next_y] == 'R') or \
|
|
||||||
# (exists(v_prev_x, v_prev_y) and
|
|
||||||
# exists(v_next_x, v_next_y) and
|
|
||||||
# grid[v_prev_x][v_prev_y] == 'R' and
|
|
||||||
# grid[v_next_x][v_next_y] == 'R')
|
|
||||||
#
|
|
||||||
# be_red = (v_prev_x >= 0 and v_prev_y >= 0 and
|
|
||||||
# v_p_prev_x >= 0 and v_p_prev_y >= 0 and
|
|
||||||
# grid[v_prev_x][v_prev_y] == 'B' and
|
|
||||||
# grid[v_p_prev_x][v_p_prev_y] == 'B') or \
|
|
||||||
# (v_next_x >= 0 and v_next_y >= 0 and
|
|
||||||
# v_n_next_x >= 0 and v_n_next_y >= 0 and
|
|
||||||
# grid[v_next_x][v_next_y] == 'B' and
|
|
||||||
# grid[v_n_next_x][v_n_next_y] == 'B') or \
|
|
||||||
# (h_prev_x >= 0 and h_prev_y >= 0 and
|
|
||||||
# h_p_prev_x >= 0 and h_p_prev_y >= 0 and
|
|
||||||
# grid[h_prev_x][h_prev_y] == 'B' and
|
|
||||||
# grid[h_p_prev_x][h_p_prev_y] == 'B') or \
|
|
||||||
# (h_next_x >= 0 and h_next_y >= 0 and
|
|
||||||
# h_n_next_y >= 0 and h_n_next_y >= 0 and
|
|
||||||
# grid[h_next_x][h_next_y] == 'B' and
|
|
||||||
# grid[h_n_next_x][h_n_next_y] == 'B') or \
|
|
||||||
# (exists(h_prev_x, h_prev_y) and
|
|
||||||
# exists(h_next_x, h_next_y) and
|
|
||||||
# grid[h_prev_x][h_prev_y] == 'B' and
|
|
||||||
# grid[h_next_x][h_next_y] == 'B') or \
|
|
||||||
# (exists(v_prev_x, v_prev_y) and
|
|
||||||
# exists(v_next_x, v_next_y) and
|
|
||||||
# grid[v_prev_x][v_prev_y] == 'B' and
|
|
||||||
# grid[v_next_x][v_next_y] == 'B')
|
|
||||||
#
|
|
||||||
# if be_blue:
|
|
||||||
# grid[x][y] = 'B'
|
|
||||||
# elif be_red:
|
|
||||||
# grid[x][y] = 'R'
|
|
||||||
# x += 1
|
|
||||||
# y += 1
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
# Doesn't need any 'two rows are not the same'
|
||||||
array = [['B', ' ', ' ', ' '],
|
array = [['B', ' ', ' ', ' '],
|
||||||
['B', 'B', ' ', ' '],
|
['B', 'B', ' ', ' '],
|
||||||
[' ', ' ', ' ', ' '],
|
[' ', ' ', ' ', ' '],
|
||||||
|
@ -85,4 +12,16 @@ if __name__ == "__main__":
|
||||||
grid = Grid(len(array), array)
|
grid = Grid(len(array), array)
|
||||||
print(grid)
|
print(grid)
|
||||||
grid.solve()
|
grid.solve()
|
||||||
|
print(grid)
|
||||||
|
|
||||||
|
# This one does
|
||||||
|
array = [['B', 'B', ' ', ' ', ' ', ' '],
|
||||||
|
[' ', ' ', ' ', ' ', ' ', 'B'],
|
||||||
|
['B', 'B', ' ', 'B', ' ', ' '],
|
||||||
|
['B', ' ', ' ', ' ', ' ', ' '],
|
||||||
|
[' ', ' ', ' ', 'R', ' ', ' '],
|
||||||
|
[' ', ' ', 'R', ' ', ' ', ' ']]
|
||||||
|
grid = Grid(len(array), array)
|
||||||
|
print(grid)
|
||||||
|
grid.solve()
|
||||||
print(grid)
|
print(grid)
|
Loading…
Reference in a new issue