Slitherlink, Minisat, and Emscripten

This is a demonstration of using the minisat SAT solver to solve slitherlink puzzles in your web browser. I generated a javascript version of minisat by using emscripten, which compiles any language that LLVM likes into javascript's ASM. They claim that the result can run at near-native speed. My experience is consistent with that. Again: The puzzle is not being solved by a server somewhere. The solver is written in (or compiled to) javascript, and running in your browser.

How it solves

Click to solve the following puzzle (The initial puzzle is a very simple example. To show off the solver, use the examples at the bottom of the page.) :

Edit Puzzle

Edit the puzzle by clicking in a box and selecting the new number. Change the rows and columns below:
Rows:
Columns:

Enter a new puzzle

Enter a new puzzle here:

Then click .

The solver accepts either of the following two formats.

One puzzle description format is: WxH:S, where W and H are integers indicating the width and height of the board (in squares, not points) and S is a string of characters that indicates where the numbers are placed on the board, from left to right and top to bottom. A lower case letter is used to indicate one or more blank squares: a = 1, b = 2, etc. Here's an example you can copy and paste into the new puzzle box:

45x31:d1a111b111c02a13a21a13a3a323b022a2d3132b331b102q232b132b23232312k30a22a22a20a22l3232n2o3r211b112a0b20a20a02a23a1b3a303b232d212a013b013u323b323a323121j331a20a33a20a22a231j232e3b020b1a0m2a0b333b0e3b2b3a1d121b1a3a2a2a3b011d1a2b2b1a01e2h0a3a2a1a1a1h3e20b12a3a02c322b1k2b303c02a0a12a0j0a1a1b1a2a2a3a3b3a3a3j2b0a0a3a30a113b1b1a2a2a1b2b303a01a3a3a3q1b1a1a1a1a1b1o2a3a3a0b101d1b1a1a1a3b1d112b3a3a3a20b1a1c1a3a2a1b3a1a1a2a1b1a3a2a1c0a1b02a3a3a3b101d3b2a1a2a2b1d020b3a3a3a2o3b3a1a1a3a2b3q3a3a3a30a223b1b1a3a1a2b3b322a23a3a3a3b3j2a2a2b1a1a2a2a1b3a2a0j1a13a3a10c022b2k1b223c13a0a31b23e3h2a2a1a3a1a0h1e10a0b1b0a0d333b3a3a0a3a1b123d2a0b3b3e3b333b0a0m2a0b220b2e202j333a31a12a33a13a222j111211a232b232u302b303a101d303b303a0b2a12a01a31a01b0a311b232r3o3n2233l02a30a31a20a02k23222222b303b212q222b101b0323d2a232b101a2a20a10a31a20c202b323a1d

The other puzzle description consists of 0-3 in the locations where that's the constraint, and a period where there is no constraint. Here's an example you can copy and paste into the new puzzle box (It results in the same puzzle as the previous example):

....1.111..111...02.13.21.13.3.323..022.2....
3132..331..102.................232..132..2323
2312...........30.22.22.20.22............3232
..............2...............3..............
....211..112.0..20.20.02.23.1..3.303..232....
212.013..013.....................323..323.323
121..........331.20.33.20.22.231..........232
.....3..020..1.0.............2.0..333..0.....
3..2..3.1....121..1.3.2.2.3..011....1.2..2..1
.01.....2........0.3.2.1.1.1........3.....20.
.12.3.02...322..1...........2..303...02.0.12.
0..........0.1.1..1.2.2.3.3..3.3.3..........2
..0.0.3.30.113..1..1.2.2.1..2..303.01.3.3.3..
...............1..1.1.1.1.1..1...............
2.3.3.0..101....1..1.1.1.3..1....112..3.3.3.2
0..1.1...1.3.2.1..3.1.1.2.1..1.3.2.1...0.1..0
2.3.3.3..101....3..2.1.2.2..1....020..3.3.3.2
...............3..3.1.1.3.2..3...............
..3.3.3.30.223..1..1.3.1.2..3..322.23.3.3.3..
3..........2.2.2..1.1.2.2.1..3.2.0..........1
.13.3.10...022..2...........1..223...13.0.31.
.23.....3........2.2.1.3.1.0........1.....10.
0..1..0.0....333..3.3.0.3.1..123....2.0..3..3
.....3..333..0.0.............2.0..220..2.....
202..........333.31.12.33.13.222..........111
211.232..232.....................302..303.101
....303..303.0..2.12.01.31.01..0.311..232....
..............3...............3..............
2233............02.30.31.20.02...........2322
2222..303..212.................222..101..0323
....2.232..101.2.20.10.31.20...202..323.1....

Here's another big one:

50x50:3b2b1a3b2a232a33a2b33223a2b32a112b3b33a22b3d22d1b1d1b22a2a2a2c3a3b1b2a1c113a1a21b1a32a12112a1a2a2b3b1223a2b1c21d3d122a12a22e22b1a1d3b312a2d22a3a2a32a2b221b3a202a222a2332d3a2b323a12b23a2b21a2a123d1a2a21b02a121a232a1b12a22a3a1a1a1b0b1a223b23e1c2a32b22e2c2a12a32233f02f3b2a3b2a11a1a2b3b30b3e1a2a1a1321a33a312a22a22b0e3b2a2a3a3e2b2a2a3a3b22a2f21e3b21c2b3e3b1a1c2c2b33b3a33d10b1a2a3a2a3a32a2a3a3a02c1e22e1c312a122c212b131e2c22b2a233a2a1b2a3a3c3e223b1b3b2c3a1a1a22a12221a3a2b22a3c1d2c222a2a2c1a3a132a2b0b32b1b23a22a2a2d0b3123a32a1b3a22b1b2c1c1c3c231d212c2d11b21a1a2b1b2c2a1b22a111a2b3a31d3e3d2a3b1a2d2b21c3c1b21a0f21a1a2b2a3a1b1a2d2a23a22a212a0c2e2a23a22d3d21c1a212d2a1a232c13a1b2a1b3b312a23b3c2a2a2a2b2a22113f2f1222a1a1b2a33110a1a2a1121a12a22a1d32c02a2a1d31b1a3g32a2a2b1d1a21b3a2c0a2b3c3b11a3a2a12c32d1311a31a3a21b220a0f22g13a3a0a2a121a2b13a212a12l312223a2a3a21a2c2a33f3a2b2f2e3a10b22b0211a223a1a2b212232a2a2e23a311a2a211b2c22e2a3b2b23i3a2a3a1b1a221b22b1e122h23b3b232a22222e3a21a220a222a1a3c3b2a2a3b120a2a21a2a12121322021a12a0b3b0b03a21b3a312b2d3b1a11c3b23e21a1a32e3c2a2d1a11b22b3b222b22b213a3b1a2b13a2b1a2e1a221a02a32c2b3a12g1g1b2b3c23b3a1a33a3c2a2a2b12a211a11a1a2a122311b20a1a11b22a2d12a2e1a221a2a20b0a3a3b2a1a2a21c3b3c222d23a11a2d2b2a3d2f1b1b2b3221d3a13b223a32c1b2c1b1c01a0b213a3b2a322a2a2b1b21b1b2a3a213a3f12a222b2c2a2a1c3221a1a222a22b2a1131221c01f122d0b1a1a1f2a222a22c3e2c23a1a21d2d32a2b3b12d21d221b2b1b212a3a20c02a3a3a223a3a222a1a2g1b232c33a3a2e32b21b3a32a1c2a11a3a2a3132a31a2c1a2a2b03a1c2a3a3b1a112212222c3a1b12b231e31b3a2c1d2b1b1f22a2a21c1c2d231d3b3d222b0b10c2a0b2e3e12a23b3f22a22a12c21b2a021b3c3a1223a2a321d3b11c3a2112a2b1a2b3d1c1a2a221c3c1b2b0a3231g2a2a3b1b22a0c2a3a2b1b32a2a2a3b2b222b2a2a3b122a32a21a3a303b3a1232b2d1a3a2d2a2a3c121a1a1b2c2d2b3222a2b3c2d33a323b3a13a2b3b2d2a22a2b3

Comments to doug[at]DougAndJean[dot]com