Sudoku and Exact Cover problems

Sudoku is an example of an Exact Cover problem and can be solved by picking a subset of candidate rows from the exact cover matrix that satisfy all of the constraints for the complete grid.

I explored building an implementation of Donald Knuth’s Algorithm X using Dancing Links as a Sudoku solver, which you can read more about here.

For a 9×9 Sudoku puzzle, a candidate grid has x possible candidates, by y constraints.

For a 9×9 grid using numbers 1 through 9, there are:

9 rows x 9 columns x 9 (values 1 through 9) = 729

… possible candidate values for the cells.

For 4 constraints applied to every cell in the 9×9 grid, there are

9 rows x 9 columns x 4 constraints = 324

… constraints to be met.

If you fill a grid where a 1 represents a met constraint by that candidate and 0 is unmet, if you zoom out far enough the table looks like this:

To see how a matrix like this is used together with Donald Knuth’s Algorithm X and Dancing Links, see my previous post here.

Upgrading cmake on Raspbian Jessie

Trying to build and install rtl-sdr from source I got this error on a Raspberry Pi 1 running Jessie:

$ cmake ../

CMake Error at CMakeLists.txt:22 (cmake_minimum_required):
CMake 3.7.2 or higher is required.  You are running version 3.6.2

Doing an ‘apt-get update’ and ‘apt-get upgrade’ is not picking up a more recent version, so following the steps here, I downloaded the required 3.7.2 version from source and followed the steps to build it: http://osdevlab.blogspot.com/2015/12/how-to-install-latest-cmake-for.html

I downloaded a .tar for the 3.7.2 version from:

https://cmake.org/files/v3.7

The build look over 2 hours, but completed successfully, and now I’m able to build rtl-sdr.