For techies: the program does a backtrack search, choosing the next cell to guess which minimises the fanout.
Here’s a question for those reading the source code: if x is an (binary) integer, what does (x & -x) compute?
Hope you have fun playing with this. Please tell me if you find any bugs! – LHL
As several of you noted, (x & –x) returns the least significant ‘1’ bit of x, i.e. the highest power of two that divides x. This assumes two’s complement notation for negative numbers, as some of you also pointed out. e.g. if x=12 (binary 1100), then (x & -x) = 4 (binary 100). I didn’t invent this; it is an old programming trick.