diff --git a/sources/main.py b/sources/main.py index a6dc28b..f925c8d 100644 --- a/sources/main.py +++ b/sources/main.py @@ -1,83 +1,10 @@ __author__ = 'gaugendre' 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__": + + # Doesn't need any 'two rows are not the same' array = [['B', ' ', ' ', ' '], ['B', 'B', ' ', ' '], [' ', ' ', ' ', ' '], @@ -85,4 +12,16 @@ if __name__ == "__main__": grid = Grid(len(array), array) print(grid) 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) \ No newline at end of file