starting work to implement that all lines (and columns) must be different
This commit is contained in:
parent
ba8507d38a
commit
6fee91e0c4
1 changed files with 26 additions and 2 deletions
|
@ -18,6 +18,13 @@ __author__ = 'gaugendre'
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def string_from_list(line):
|
||||||
|
string = ""
|
||||||
|
for square in line:
|
||||||
|
string += square.state
|
||||||
|
return string
|
||||||
|
|
||||||
|
|
||||||
class Grid:
|
class Grid:
|
||||||
def __init__(self, size, array=None):
|
def __init__(self, size, array=None):
|
||||||
_squares = []
|
_squares = []
|
||||||
|
@ -58,7 +65,16 @@ class Grid:
|
||||||
representation += "\n"
|
representation += "\n"
|
||||||
return representation
|
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:
|
for square in self.square_list:
|
||||||
if square.is_empty():
|
if square.is_empty():
|
||||||
v_prev = square.prev_vert()
|
v_prev = square.prev_vert()
|
||||||
|
@ -92,8 +108,9 @@ class Grid:
|
||||||
|
|
||||||
def solve(self):
|
def solve(self):
|
||||||
for i in range(0, 2, 1):
|
for i in range(0, 2, 1):
|
||||||
self.solve_three()
|
self.solve_three_in_a_row()
|
||||||
self.solve_same_number()
|
self.solve_same_number()
|
||||||
|
self.solve_different_lines_or_columns()
|
||||||
|
|
||||||
def solve_same_number(self):
|
def solve_same_number(self):
|
||||||
for square in self.square_list:
|
for square in self.square_list:
|
||||||
|
@ -127,6 +144,11 @@ class Grid:
|
||||||
elif count_blue == self.size / 2:
|
elif count_blue == self.size / 2:
|
||||||
square.state = 'R'
|
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:
|
class Square:
|
||||||
"""
|
"""
|
||||||
|
@ -255,6 +277,7 @@ class Square:
|
||||||
"""
|
"""
|
||||||
line_list = []
|
line_list = []
|
||||||
line_list.extend(self.all_prev_horiz())
|
line_list.extend(self.all_prev_horiz())
|
||||||
|
line_list.append(self)
|
||||||
line_list.extend(self.all_next_horiz())
|
line_list.extend(self.all_next_horiz())
|
||||||
return line_list
|
return line_list
|
||||||
|
|
||||||
|
@ -266,5 +289,6 @@ class Square:
|
||||||
"""
|
"""
|
||||||
line_list = []
|
line_list = []
|
||||||
line_list.extend(self.all_prev_vert())
|
line_list.extend(self.all_prev_vert())
|
||||||
|
line_list.append(self)
|
||||||
line_list.extend(self.all_next_vert())
|
line_list.extend(self.all_next_vert())
|
||||||
return line_list
|
return line_list
|
||||||
|
|
Loading…
Reference in a new issue