

The number of valid Sudoku solution grids for the standard 9×9 grid was calculated by Bertram Felgenhauer and Frazer Jarvis in 2005 There are many more ways to add more variants by making use of this 642 base puzzles.

Have added some code that will turn this 642 puzzles randomly into approximately 21.037056 million different puzzles (give or take a few should my reasoning be correct) when the "New puzzle" button is pressed. There are 642 base puzzles in this B4A project. Solve(sudoku1, nextX, nextY) 'SUB ALSO CALLING ITSELF If (checkSquare(sudoku1, cellX, cellY, checkNum) AND checkRow(sudoku1, cellY, checkNum) AND checkCol(sudoku1, cellX, checkNum)) Then 'delay to process the stack before returning control to the B4A UI? Solve(sudoku1, nextX, nextY) 'SUB IS CALLING ITSELF - is it adding too much to the stack and then once a solution has been found the excessive Label1.Text = "Solved puzzle No " & randnum & " in " & (endtm - starttm) & "ms" Log("Solved puzzle No " & randnum & " in " & (endtm - starttm) & "ms") 'IS IT BUSY PROCESSING EVERYTHING THAT HAS BEEN PUSHED ONTO THE STACK BEFORE IT RETURNS CONTROL TO THE UI? 'I SOMEHOW NEED TO EXIT FROM HERE AS THE SOLUTION HAS BEEN FOUND How do we exit from here as fast as possible? 'If the y value is 9 then the sudoku has been solved.

Sub solve(sudoku1(,) As Int, cellX As Int, cellY As Int) The zipped java source code that the library files (jar and xml) were generated from The B4A project (with library files in the /files folder - copy it to your additional library folder)Ģ. Take note that generating new Sudoku puzzles can take a while.ġ. Then click/press "Solve" to solve the puzzle. It will report the number of non-zero cells in the newly created puzzle. Just click/press on "Solve" and the puzzle will be solved (it also reports the time taken in milliseconds to solve the puzzle).Ĭlick/press on button "Create" to randomly create a new Sudoku Puzzle. When it starts up it will randomly select one of the Sudoku puzzles that has posted in the project that you can find here.

The library files (jar and xml) are in the /files folder of the attached project. It was adapted and then compiled to a B4A library. The code to generate Sudoku puzzles with comes from here. The code to solve the puzzles with was adapted from here (converted to B4A). The attached project will generate and solve Sudoku puzzles (9x9).
