The `ndarray`

class has a `strides`

field, which is a tuple indicating the number of bytes to step in each dimension when going through an array. Let's apply some stride tricks to the problem of splitting a Sudoku puzzle into the 3 x 3 squares it is composed of.

Explaining the rules of Sudoku is outside the scope of this book. In a nutshell, a Sudoku puzzle consists of 3 x 3 squares. Each of these squares contains nine numbers. For more information see http://en.wikipedia.org/wiki/Sudoku.

Apply the stride tricks as follows:

- Let's define the
`sudoku`

array. This array is filled with the contents of an actual, solved Sudoku puzzle:sudoku = np.array([ [2, 8, 7, 1, 6, 5, 9, 4, 3], [9, 5, 4, 7, 3, 2, 1, 6, 8], [6, ...

Start Free Trial

No credit card required