Writing - Non Fiction - Books & Manuals - How to Create Your Own Sudokus with Java (retired)

How to Create Your Own Sudokus with Java
by Giulio Zambon

ISBN: 978-1-4709-7815-0
Publisher: Self-published with Lulu
Publication date: 2011-12-03. Pages: 265.

List price: USD 29.99
Available from (2011-12-03):
    Lulu for USD 29.99 in print and from 2011-12-09 for USD 9.99 in PDF format with ISBN 978-1-4710-0285-4

Here are some PDFs that will tell you more about the book: table of contents, table of figures, and table of listings.

After reading this book, you will be able to generate all sorts of Sudokus, including pattern-Sudokus like the following one:

heart Sudoku

What follows is the Introduction section from the book.


Welcome to How to Create Your Own Sudokus with Java. The purpose of this book is to teach you how to write computer programs to solve and generate Sudoku puzzles.

This is a practical book. My intention is not to teach you how to become a software developer, but rather how to use computer programs to deal with Sudoku puzzles. Therefore, you will not find here theoretical analyses of algorithms, solvability problems, or complexity theory.

All the code I present and comment in this book conforms to the Java Standard Edition Version 6 as described in Oracle's documentation you find at http://download.oracle.com/javase/6/docs/.

For longer than a decade before writing this book, I developed software exclusively in Java and its derivatives (e.g., JavaScript and JSP). Nevertheless, I developed the first version of my Sudoku software in C. I thought that for most people it would be easier to deal with 'plain old' C rather than with Object-Oriented Java. But after publishing Sudoku Programming, I realised that programs in Java would probably appeal to a wider audience. That's why I 'translated' my software from C to Java and wrote the book you are holding in your hands (or reading on your computer screen).

Most of this book concentrates on solving Sudoku puzzles, but the main purpose of this book is to explain how to make Sudokus. There is very little information on the World-Wide Web about how to generate puzzles. Perhaps it is so because, once you have a program to create them, you can also sell them to magazines and newspapers.

Chapter 1 describes the notation I use throughout the book and how I represent Sudoku grids in Java.
Chapter 2 lists and explains the strategies I implement in the Solver program.
Chapter 3 describes the structure of the Solver and its general utilities. It also tells you how to download the sources from my website and install them on your computer.
Chapter 4 to 13 explain how I implement in C the solving strategies described in Chapter 2.
Chapter 14 tell you how to display a puzzle graphically.
Chapter 15 describes in detail the Generator program.
Chapter 16 analyses the puzzles that the Generator creates.
Chapter 17 explains how to generate Sudokus with clues that form specific patterns.
Chapter 18 shows how to build Samurai puzzles.

I have listed and explained every module. I hope you will enjoy reading and using the book as much as I enjoyed writing it.

Back-cover blurb

The purpose of this book is to teach you how to write computer programs to solve and generate Sudoku puzzles. If you love Sudoku and have some knowledge of computer programming, you will have no problem in understanding the code of my Sudoku Solver and Sudoku Generator.

I have included in the book the full listings of both programs and an explanation of each Java class, with walk-throughs and examples. To make your life easier, I have also included a description in detail of the sixteen solving strategies implemented in the Solver.

By following the instructions contained in this book, you will be able to create a practically unlimited number of original Sudokus.

To stimulate your creativity, I have also added a chapter about Samurai Sudokus, and a program to help you generate them.

This is a practical book that will provide you with everything you need to write your own books of Sudoku puzzles.


Sudokus are so popular that they systematically increase newspaper circulation. This has resulted in the publication of many books about how to solve Sudokus. But how to generate Sudokus is a highly-guarded secret. Even on The WorldWide Web the information about Sudoku-generating strategies is limited and fragmentary. The obvious explanation (although not necessarily true!) is that those who possess the programming and problem-solving skills necessary to write software capable of solving and generating Sudokus choose to sell their puzzles rather than divulge their tricks.

That's why I decided to write a book explaining in detail how to develop a Sudoku-generating program. I then immediately realised that I also had to include a program capable of solving Sudokus with as many strategies as possible. Otherwise, it would have not been possible to estimate the difficulty of the generated Sudokus, which is necessary for two main reasons:

  1. Ungraded Sudokus are unsellable, because the publishers of puzzles are only interested in Sudokus of known difficulty
  2. I wanted to be able to weed out Sudokus that could only be solved by guessing.

I started working on the software at the beginning of December 2010 and completed the book around mid February 2011. But that was the C-version of the book, Sudoku Programming. To convert the software and the text to Java, I spent the best part of June and July 2011.

As with its C counterpart, the problem with this book is that it is a serious programming book written about a puzzle. It falls outside the scope of both publishers of puzzle books and of computer manuals. Even my editor at Apress, who has been in the publishing industry for a long time, couldn't come up with any suggestion.

I had in fact expected that small publishers wouldn't take the risk and large publishers would probably ignore me. That's when I decided to self-publish it.

You can contact me at email address or send a BGG message to BloodyMe.

I like to collect little flags on BGG. Please visit my BloodyMe page there if you haven't already done it!