I've created a relatively simple Sudoku generator in Excel. This Excel file allows you to gain an intuitive understanding of how Sudoku puzzles can be generated in the basic setting of an Excel workbook. File is located on my GitHub, here:
New to Microsoft Excel? Looking for a tip? How about a tip so mind-blowingly useful as to qualify as a magic trick? You're in luck. In this MS Excel tutorial from ExcelIsFun, the 242nd installment in their series of digital spreadsheet magic tricks, you'll learn how to create a sudoku puzzle using array formulas, the INDEX function with criteria and data validation.
I have not done any cosmetic coding. The coding part is only the algorithm. You know Excel is awesome right. So, I have made the whole setup using the excel function. Setup in the sense, where we will keep the Sudoku, and how we will check allowed values. The below image is my setup.
Thanks Chandoo..I missed this post of yours.
1) Just as I did this, I was pretty much interested in creating an excel that could generate SUDOKU puzzles.
2) I haven't tried more than 10 iterations..but yes, more difficult problems would get solved if you increase the iterations in the code.
This means that unlike other approaches the algorithm runs only once and returns a sudoku configuration matching the desired difficulty (with high probability within a range or with probability=1)
Then one (after having generated a sudoku configuration) re-solves the sudoku with the human-like solver and depending on the techniques the solver used (e.g pairs, x-wing, swordfish etc.) a difficulty rate is also assigned.
The difficulty rating of the human-like techniques is very subjective. For example why x-wing is taken to be more difficult than hidden singles? (personaly have solved many difficult published sudoku puzzles manualy and never used such techniques)
Extending my previous answer, it was mentioned that for any sudoku puzzle the minimum number of clues is an objective property of the puzzle (for example for 9x9 grids the minimum number of clues for having a valid sudoku is 17)
Tests of the sudokus generated with this algorithm and difficulty rating based on the previous approaches (human-like solver), show a correlation of desired and estimated difficulty rates, plus a greater ability for generalisation to arbitrary sudoku configurations.
This would be the most difficult/hard sudoku puzzle level (i.e minimum needed number of clues). Then all other difficulty levels from less hard to easy are generated by allowing more clues than the minimum amount needed.
It should be noted that sudoku difficulty levels are not standard, as explained above, one can have as many or as few difficulty levels as one wants. What is standard is the minimum number (and position) of clues (which is the hardest level and which is relatd to the sudoku symmetries), then one can generate as many difficulty levels as one wants simply by allowing extra/redundant clues to be visible as well.
You can not delete link parts of this Excel file, or sell or share this Excel file. If anyone needs it please refer that individual to my Gumroad store or Excel Macro Fun blog.
-sudoku-generator.html
With the new capabilities of Lambda Functions, Dynamic Spill Arrays, and Recursion, Excel can actually solve ANY sudoku puzzle using only Formulas! (No macros/VBA). If you have the Add-On "Advanced Formula Environment" installed, you can add my Lambda Function to a module very easily using my GitHub Gist url:
I really enjoy your xml macro.,
btw I wanna make a cross check opname similarly your sudoku apps, but little different., there are 8 branches that are going to examine each other every month (by coloumn) randomly.,
For all of us who have studied Physics, mathematics ,engineering or economy, talking about Euler is like in football talking about Johan Cruyff ,we know what we are talking about!
Trying to create a Sudoku generator in Excel as well as a Sudoku solver, became a personal challenge. It was fantastic to present it in Excel, a mathematical game that should be able to be played and solved in the best existing calculator, Excel itself.
Easy presented in an Excel sheet whose resolution could be use many of the existing functions, we carried out the first Sudoku solver in 2004-2005.
The simplicity of the rules make it easy for beginners, however, it is not easy for many when they search online for free sudoku puzzles and they are not able to solve it, like the one present on this page.
The satisfaction of completing a puzzle may be another reason why, although in many cases we do not have the ability to solve them.We improve our skills as we play.
Here is a free Sudoku generator that can generate puzzles of varying difficulty in PDF, Postscript, plaintext, and HTML. It is a nice example of the website fun you can have with 250 lines of Python over a Labor day weekend; it also makes a handy command-line Sudoku solver...
So if you find a 17-hint puzzle, you should check to see if Gordon already has it. And remember that there is no proof that fully determined 16-hint puzzles don't exist. If you get a 16-hint puzzle out of the automatic puzzle generator, don't throw it out. It would be publication-worthy.
There is another strategy I have found, which I use for hard sudoku's on paper. Once you have worked out all the possibilities for each uncertain cell, look for a (row/column/block) that contains (2/3/4/5/6/7) different possibilities for the same number of cells in that row/column/block. Eliminate ALL of these options from all OTHER cells in that row/column/block.
Hi, i need help coding a sudoku generator and solution checker, which also provides a gui that allows the user to input numbers into the puzzle, check their input, and generate a new puzzle at any time, using a neural network and random number generators.
I wrote a sudoku solver some time back that employs a few techniques: looking for cells with unique candidates, looking for the only position for a value along a row, column, or block. I also added another technique that looks at subcolumns within a block and comparing to other subcolumns. These techniques seemed to be able to solve all the puzzles from local newspapers, but that's only because thos puzzles were pretty simple.
I believe it can probably be proven (or maybe it is already proven) that as long as the solution to a sudoku puzzle is guaranteed to be unique, there must be a logical series of steps that one can take to solve the puzzle. These steps which may include really complex technqiues -- even ones that have not even been discovered.
Using algorithms that make guesses is probably just a shortcut for not having to develop and implement complex techniques. But if you implement as many of the known techniques as possible, it would help make the generator more likely to generate a harder puzzle.
well,i think algo from shawn would b the best to generate new random sudoku's........wen u hav nothin.......and solver from david dated 28 dec,2007 is the best 1......but further isn't there any method 2 generate new sudoku's from a blank board.......i tried it this way.....first a generator which puts fixed no of random nos at random positions....follwoing possible conflicts.....then a solver which would solve this......if solver could solve it ...it's a valid sudoku.......else generator is called which generates a new sudoku from scratch.......but this gets quite typical for comp as it does guess work........can't there sum logical sol to this
Good stuff David, thanks. I wrote an solver in Excel VBA a few years back that employed a few different logical rules. It was pretty effective but could not solve the "brute force" type so recently I wrote a very simple smalltalk version that works very much the same way as your approach. I've been meaning to get around to writing a sudoku generator and this has now inspired me to get on with it!
Interesting stuff here.
What I've been wondering lately is if there is some way to generate completed sudoku puzzles from scratch. In other words a way to create a two dimensional array (9*9) which would contain the data from a completed sudoku.
Sky's way souunds alright for my purposes, but I was wondering if you could make one from scratch.
Thanks guys.
I have been reading on the subject and from what i have hear you can use the dancing links (DLX) algorithm I have used this to salve the N Queens problem but never sudoku. I think it will work though it uses linked lists.
I didn't know that there was so much fuss around creating a sudoku puzzle. I have developed SUHelper in www.charalampakis.info during my summer holidays. It is free... it creates random puzzles by rearranging a solved puzzle. I think it is rather fast, although I haven't tested it against other algorithms, nor was it my intention (to create the fastest algorithm). The program has full GUI. It can also try to solve a puzzle with logic (without guessing). Any feedback would be greatly appreciated.
Interesting... However, I don't believe the method above will generate a valid sudoku puzzle, because it uses best guess to determine if a sudoku is valid. Sudoku puzzles are supposed to be solved with logic, not trial and error.
These rules don't take into account the interaction between the boxes and the rows/columns that make a sudoku different from a latin square, though; you also need a "box-line" rule of some sort, along the lines of "if all possible locations for a given number in a given line are in the same box, then delete that number from the possibilities for all the remaining cells in that box", and the same thing interchanging line and box.