Homework 3.8 - My Solution

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's gravatar image

ReGardS-1
2612411
accept rate: 33%

Be the first one to answer this question!
Question text:

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×15,238
×1,718
×195
×103
×13

Asked: 28 Mar '12, 03:21

Seen: 130 times

Last updated: 28 Mar '12, 03:21