October 1, 2006

Raging Rapids

Filed under: Scripts, Puzzles — mark @ 10:44 am

I’ve added a write-up for the ‘Raging Rapids’ puzzle by ThinkFun. A reader mentioned it in an email comment to the Scramble Squares Solver … he had knocked over a friend’s board and needed to get it solved pronto. It was a good insight … Raging Rapids is in many ways a simpler puzzle than Scramble Squares, but a close cousin. The depth-first algorithm is easily modified to provide the ‘correct’ solution, and can be adapted to explore for some novel ones as well.

April 18, 2006

On the Move

Filed under: Scripts, Observation — mark @ 9:53 am

I am lurching toward a new site design that is driven off of my WordPress-powered blog.  This works well for a lot of my previous pages and site usage.  It is a problem for the puzzle pages, which often include running “Solvers”.  For these, I’ve added a section to the sidebar for ‘Puzzle Pages’, and am slowly but surely shoehorning the popular ones (the Jumble, Scramble Squares, and Word Mining solvers in particular) into a page with a design based on the blog.  After managing that, the site should require far less maintenance attention from me.

February 22, 2006

Wrong Division

Filed under: Scripts, Puzzles — mark @ 4:21 pm

I am fascinated by web statistics … the information that you can pull out of the server logs that give you some idea of the usage patterns on your site. After several years of working on PC software and its endless marketing wars over features you could never actually convince yourself that anybody cared about, an opportunity to build applications on a platform that actually recorded what got used and when was an intoxicating invitation.

So I often find myself digging down into my web stats to find out how (sometimes if) people use my Puzzle applications. I have learned a few things:
 
 

-   I am helping a Very Large number of people turn the tables on the Jumble. Seriously. Hundreds a day sometimes. This surprises me, since the page was really just intended to implement Jon Bentley’s nifty algorithm for unscrambling words … the Puzzle itself is perfectly suited to the playful side of the human mind … devoting algorithm design time to the problem is only useful if it helps to teach how to think through trickier problems.
-   Scramble Squares puzzles are Very Popular although almost Nobody wants to deal with a puzzle solver that requires them to do any work. Users either get their answer on the first or second try, or else they frantically tweak their initial entries twenty different ways, and then email me to ask if I have the answer to their puzzle. In other words, teach a man to fish, and he’ll sadly shake his head and then ask you for a fish.
-   Cryptograms. My Solver works with what the American Cryptogram Association (ACA) calls ‘aristocrats’, which are simple letter-substitution encodings of messages that otherwise maintain the word divisions and punctuation of the original message. In their bimonthly magazine “The Cryptogram” the ACA will publish 25 Aristocrats, and the Solver (based in PHP) will usually manage to solve about half of the set … the ACA cons are submitted by members, many of whom are well onto what makes for a difficult puzzle, and the Solver will bail on anything that threatens to consume too much processing time. Its Perl-based big brother will handle them all, sometimes with a little hand-holding, so let me know if you’re stumped.

People using the Solver are often seized with the desire to feed it with a stream of hundreds of random characters from their keyboards (without spaces or other word divisions) looking for, I don’t know, messages from the Other Side expressed as a sort of systematically encoded Automatic Writing?

Others are fond of submitting single encoded words with the implicit question of (I guess) ‘What word does it encode?’ The explicit answer is ‘What word doesn’t it encode?’ …
after accounting for word length and repeated characters, the answer will usually be any one of thousands of alternatives!

Lately, someone has been sending in lots of ‘Patristocrats’. These puzzles are encoded like Aristos, but all punctuation and natural word divisions have been removed. For example, a quote from Douglas Adams, encoded as an Aristo:

gwdcd rp v gwdecq swriw pgvgdp gwvg rz dydc vxqjelq
lrpieydcp dhvigaq swvg gwd kxrydcpd rp zec vxl swq rg rp
wdcd, rg sraa rxpgvxgaq lrpvuudvc vxl jd cduavidl jq
petdgwrxb dydx tecd jrfvccd vxl rxdhuarivjad. gwdcd
rp vxegwdc gwdecq swriw pgvgdp gwvg gwrp wvp vacdvlq
wvuudxdl

The Solver will work through this almost instantly ("There is a theory which states that if ever anybody discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable. There is another theory which states that this has already happened.") But a Patristocrat version of the same puzzle lacks any punctuation, and groups the letters in even groups:

gwdcd rpvgw decqs wriwp gvgdp gwvgr zdydc vxqje
lqlrp ieydc pdhvi gaqsw vggwd kxryd cpdrp zecvx
lswqr grpwd cdrgs raarx pgvxg aqlrp vuudv cvxlj
dcdua vidlj qpetd gwrxb dydxt ecdjr fvccd vxlrx
dhuar ivjad gwdcd rpvxe gwdcg wdecq swriw pgvgd
pgwvg gwrpw vpvac dvlqw vuudx dlabc

The Solver will look at this a long time with the single computer-brain thought, "Man! That’s a lot of 5-letter words!"

Although there are crypto-wonks out there who will giggle at my naivete (weirdos), I have thought about this a lot and I just have not come up with a fast way to solve Patristocrats. If the message is long enough, basic letter-frequency analysis will get you most of the way there (figure out the first-, second-, and third-most-used letters and assign these to ‘e’, ‘t’, and ‘a’, and you’re off to the races), but otherwise the words do very little to reveal themselves.

January 19, 2006

Only Myself to Blame

Filed under: Scripts, Puzzles, Observation — mark @ 9:49 am

I received a very persnickety, if I may use that word, email from another denizen of the UK taking me to task for the sad truth that some of the Sudoku puzzles I am coughing up have multiple solutions. Apparently I have transgressed the unwritten law.

True enough, sometimes they do. My old Sudoku puzzle page, ‘The Sudoku Challenge’ had this problem in a big way, offering puzzles with hundreds of alternative solutions, and it took me an embarrassing amount of time to figure this out. (What finally tipped me off was seeing it propose a puzzle with a single number ‘9′ in the middle of an otherwise empty board.)

My main blind spot was having originally approached Sudoku with an eye to solving the puzzles via computer, which turns out to be extremely easy to do. So easy, in fact, that you don’t realize that a computer program has exactly the sort of mind-numbing persistence that it takes to grind through incredibly abstract boards with dizzying speed.

In practice, I’ve found that the most satisfying Sudoku boards have only one solution, and that solution can be arrived at completely via deduction … that at every step, there is always one square on the board that can take one, and only one, possible value. You can make it a little harder by adding a step along the way where the best you can do is make a guess once during the game (that is, your best opportunity is a square that looks like it will support at least two different numbers). Of course, the moment you introduce that possibility, you also introduce the chance that either number will lead you to a valid solution (which sometimes happens), and the Slough of Despond that Non-Unique Solutions inevitably lead us to.

Boards that require more than one guess are beneath contempt, and a Sign of the End Times, as far as I’m concerned.

On the new puzzle blog, The Puzzle Machine, I offer three Sudoku puzzles a day (and one cryptogram), one requiring no guesses, one requiring one guess, and the third requiring two. My Linux box has solved them all, but I, frankly, never touch those two-guess monstrosities.

January 11, 2006

When Sudoku Gets Nasty

Filed under: Scripts, Puzzles — mark @ 12:32 pm

I got an email from a reader that had come across our Sudoku Solver, but found that it choked on the World’s Biggest Sudoku Puzzle created by Sky One in the UK (or most creative Photoshop creation … Guinness Book Record or not, I can’t decide which it is). Most Sudoku boards are considered tough if you have to make a guess for your next move more than a couple of times, but the Sky One puzzle demands a sequence of no less than 10 correct guesses on the way to one of its solutions (there are two).

Our little PHP-based solver gives up when the recursion goes too deep, but it comes from a Perl script we’ve written that has no such qualms. I’ve published a description of this script and the script itself in the article about Tough Sudoku.