## sudoku solution verifier – python

### Aside

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]`

## riddle 2 (python)

### Aside

same as last time, highlight to see answer(s), in python, below.

```
def fn(*args):
x = '/'.join(str(i) for i in args[:3])
y = '/'.join(str(i) for i in args[3:])
return abs((datetime.strptime(x,"%Y/%m/%d")-datetime.strptime(y,"%Y/%m/%d")).days)

fn(2001,1,1,2002,2,2)

#depending on input format, could do a one-liner:

def fn(x,y): abs((datetime.strptime(x,"%Y/%m/%d")-datetime.strptime(y,"%Y/%m/%d")).days)

#it's probably possible to replace "%Y/%m/%d" with "%c"
```

`[More programming riddles]`