sudoku solution verifier – python


write a sudoku solution verifier in python.

that is, given a list of lists, representing a solution to an nxn sudoku puzzle, verify that the solution is a correct sudoku solution:

fn ([[1,2],[2,1]]) # True
fn ([[1,3],[2,1]]) # False

(question seen as a Udacity programming course homework question)

highlight to see a solution:

def fn(x):
    b = [(j + 1) for j in range(0,len(x))]
    for i in x:
        if sorted(i) != b: return False
    return True

[More programming riddles]