1Jan

Lightning Brain Sudoku Generator For Mac

1 Jan 2000admin
Lightning Brain Sudoku Generator For Mac 3,9/5 8634 votes

#Sudoku

Sudoku Latin Squares for iPad, iPhone, Android, Mac & PC! Get in on the sublime number puzzle that has the whole world playing.! Sudoku Generator is an online tool to generate Sudoku puzzle of different degree of difficulty. It creates 9X9 Sudoku Puzzles starting from easy to very hard level. Even further, it has the toughest 'inhuman' level, which creates the challenging puzzle for even the expert or experienced Sudoku player.

A Sudoku library for Java and Android.

It features a Generator to generate random Sudoku Grids of various complexity as well as a Solver to solve any provided GridGmad easy addon extractor. using backtracking.

##What is Sudoku?

Sudoku is a logic-based, combinatorial number-placement puzzle. The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 sub-grids that compose the grid (also called 'boxes') contains all of the digits from 1 to 9.(Source Wikipedia)

###Example

##APIThis library basically features three classes

  • Generator: Generates random Sudoku Grids of various complexity.
  • Grid: Represents a Sudoku Grid and features a variety of convenient methods.
  • Solver: Solves any provided Grid using backtracking.

For detailed information check the javadoc.

###How to use Generator?In order to generate a new, random Sudoku Grid the Generator class features a straightforward generate() method.This method takes the numberOfEmptyCells as parameter. This parameter controls the complexity of the resulting Grid for human players.The complexity increases with a higher amount of empty cells. The example Grid shown above contains 42 empty cells.

###How to use Grid?In order to display the Grid in your application you have to iterate over the Grid utilizing its getSize() and getCell() functions.For console-based application you may also use its convenient toString() method which produces a textual representation as shown in the example grid above.

In order to create a Grid using standard Java data types you can use a two-dimensional array of integers and Grid's static factory method of.

###How to use Solver?The solver solves any valid Grid using backtracking.

####Backtracking

#####MotivationThe reason I created this library was that I wanted to understand how to solve a Sudoku puzzle programmatically.

I was afraid that a sort of 'brute force' technique will take too long. Thus, my first solution followed the concept of 'candidate search'. This lead to many lines of code and only worked for simple - medium level Sudokus.At a certain point I needed to make assumptions anyway, so I started to use backtracking. Very quickly I've thrown away my solution and started to use backtracking completely, which simplified the algorithm's code a lot.

#####AlgorithmBacktracking is brute force. The algorithm takes the first valid value and goes on with this approach until the puzzle is solved or there is no more valid value left. If there is no more valid value left (but the puzzle is not solved yet) it tracks back to the last known valid value and tries another value.

That way the algorithm will always find a valid solution unless the initially provided puzzle is invalid! It will even fill an empty puzzle (with no pre-filled cells at all) which makes it also ideal to be used to generate new puzzles. Animated hud for mac.

However, backtracking is a perfect example for recursion. Below is all the code it takes so solve any Sudoku puzzle.