starting work to implement that all lines (and columns) must be different

This commit is contained in:
Gabriel Augendre 2015-01-02 20:45:51 +01:00
parent ba8507d38a
commit 6fee91e0c4

View file

@ -18,6 +18,13 @@ __author__ = 'gaugendre'
import sys
def string_from_list(line):
string = ""
for square in line:
string += square.state
return string
class Grid:
def __init__(self, size, array=None):
_squares = []
@ -58,7 +65,16 @@ class Grid:
representation += "\n"
return representation
def solve_three(self):
def squares_on_line(self, line_number):
return self.squares[line_number]
def squares_on_column(self, col_number):
col = []
for line in self.squares:
col.append(line[col_number])
return col
def solve_three_in_a_row(self):
for square in self.square_list:
if square.is_empty():
v_prev = square.prev_vert()
@ -92,8 +108,9 @@ class Grid:
def solve(self):
for i in range(0, 2, 1):
self.solve_three()
self.solve_three_in_a_row()
self.solve_same_number()
self.solve_different_lines_or_columns()
def solve_same_number(self):
for square in self.square_list:
@ -127,6 +144,11 @@ class Grid:
elif count_blue == self.size / 2:
square.state = 'R'
def solve_different_lines_or_columns(self):
pass
# for square in self.square_list:
# line = string_from_list(square.same_line())
class Square:
"""
@ -255,6 +277,7 @@ class Square:
"""
line_list = []
line_list.extend(self.all_prev_horiz())
line_list.append(self)
line_list.extend(self.all_next_horiz())
return line_list
@ -266,5 +289,6 @@ class Square:
"""
line_list = []
line_list.extend(self.all_prev_vert())
line_list.append(self)
line_list.extend(self.all_next_vert())
return line_list