Implementing a sudoku-solver in Python

Let's now explore my refactored implementation of the solver. I'm going to present the code to you in steps, as it is quite involved (also, I won't repeat the source name at the top of each snippet, until I move to another module):

# sudoku/algo/solver.pyimport osfrom itertools import zip_longest, chainfrom time import timedef cross_product(v1, v2):    return [w1 + w2 for w1 in v1 for w2 in v2]def chunk(iterable, n, fillvalue=None):    args = [iter(iterable)] * n    return zip_longest(*args, fillvalue=fillvalue)

We start with some imports, and then we define a couple of useful functions: cross_product and chunk. They do exactly what the names hint at. The first one returns the cross-product between two iterables, ...

Get Learn Python Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.