So in the Unit 5 After Hours, Dave and Peter suggested that we post coding solutions that could compete with their solutions, so I'm going back to Sudoku to show my solution. The approach I used is to create a procedure that checks horizontal and vertical duplication at the same time, row/column by row/column.
This is a bold step for me, as I am a total newbie, but I would still love to hear some feedback.
Thanks!
def check_sudoku(square):
vcount = 0
while vcount < len(square):
vertical = []
for nested_list in square:
sample = nested_list.pop()
if sample in nested_list or sample in vertical or sample < 1 or sample > len(square):
return False
else:
vertical.append(sample)
vcount = vcount +1
return True
asked
28 Mar '12, 03:21
ReGardS-1
261●2●4●11
accept rate:
33%