TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
 Specialized Dev Zones Research Center eBook Library .NET Java C++ Web Dev Architecture Database Security Open Source Enterprise Mobile Special Reports 10-Minute Solutions DevXtra Blogs Slideshow

# Build a Sudoku Puzzle Game Generator and Solver for PocketPC

## Not only can you generate your own Sudoku puzzles with this mobile application, but you can solve them, too—even puzzles you enter from newspapers or books.

 Mar 1, 2006
 Page 1 of 4
he Sudoku game is the latest craze in the UK, and it's become so popular that every major newspaper now publishes puzzles with varying difficulty levels. I've found the process of solving Sudoku puzzles fascinating ever since I first saw one in the London Evening Standard newspaper. But after solving a few, I decided it would be even more interesting to write an application capable of both generating and solving Sudoku puzzles. In this article you'll see how to use Windows Mobile 5.0 and Visual Studio 2005 to create such an application.

Sudoku originated in Japan. The name is is an abbreviation for a Japanese expression that translates to "The digit must remain single."

There are many Sudoku variants, but by far the most popular is a 9 x 9 grid, divided into 3 x 3 regions. The grid is partially filled with the numbers 1 to 9. The challenge is to complete the remaining cells in such a way that:

 Figure 1. New Project Dialog: The figure shows the process of creating a new PocketPC Project in Visual Studio 2005 with Windows Mobile 5 installed.
• Every row contains a number in the range 1 to 9, each number occurring once.
• Every column contains a number in the range 1 to 9, each number occurring once.
• Every 3 x 3 region contains a number in the range 1 to 9, each number occurring once.
Creating a Windows Mobile 5 Project

 Author's Note: I developed this project on Visual Studio 2005 Beta 2.

 Figure 2. Sudoku Solver: The figure shows a finished version of the Sudoku Solver project running on a PocketPC.
After downloading and installing Windows Mobile 5, you'll see several new items in the New Project dialog. To begin, create a new Windows Mobile Smart Device project (see Figure 1).

Choose the Device Application template, name the new project "SudokuGUI," and select a project location.

Next, add a second Smart Device project to your application. This time, choose the Class Library project template and name the new project "Solver." Solver contains all the logic for generating and solving Sudoku grids while the SudokuGUI project focuses mainly on the user interface—displaying the puzzle and accepting input. Figure 2 shows a running version of the SudokuGUI project.