Target and Sudoku
There is a game called target in my newspaper where you are given 9 letters and have to find anagrams of some length with one particular letter included. I wanted to beat some people at it, so I wrote a target solver. It works the obvious brute force way (use as ./target.rb ninelettr).
There is another game called Sudoku, which I don't think goes by any other names so it shouldn't need an intoduction, and I wanted to beat some people at it too, so I wrote a sudoku solver. It works by picking a blank square and assuming it is 1, then trying to solve the rest of the puzzle. If it finds a solution, then we win, if it doesn't, then it assumes that the current blank square is a 2 and tries to solve the rest. Repeat and recurse. (Use as ./sudoku.rb puzzle where puzzle is a text file containing 9 lines, each with 9 numbers. Use '0' for blanks. Output isn't pretty.)
For my purposes, I only needed to do 4 target questions and 3 sudoku puzzles, so this is reflected in the quality of the code.
Both programs get a BSD license just for a change.

RSS