Can't find any test cases for which my code for sudoku is marked incorrect

def check_sudoku(list):
n = len(list)
test = []
i = 1
valid = 1
while i <=n :
    test.append(i)
    i = i+1
for e in list:
    j = 0
    while j < n:
        if test[j] not in e:
            valid = 0
            break
        j = j+1
    if valid == 0:
        return False
k = 0
while k < n:
    column = []
    c = 0
    while c <n:
        column.append(list[c][k])
        c= c +1
    j = 0
    while j < n:
        if test[j] not in column:
            valid = 0
            break
        j = j+1
    if valid == 0:
        return False
    k = k+1
return True

asked 14 Mar '12, 10:19

Jagdeep%20Rangi's gravatar image

Jagdeep Rangi
183
accept rate: 0%


One Answer:

Did you try all of these tests? (I assume you did since you searched the forum before posting your question!)

If yes and they're all ok it's probably a problem with formatting of your code. Then read this and resubmit. If you get a correct then, close or delete this thread and be happy ;-)

If one of the tests is not ok: et voila, you found a test case for which your procedure fails.

link

answered 14 Mar '12, 10:29

Sebastian%20Weichwald-1's gravatar image

Sebastian We...
1.6k31634

edited 14 Mar '12, 10:30

Your answer
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,262
×118

Asked: 14 Mar '12, 10:19

Seen: 85 times

Last updated: 14 Mar '12, 10:30