File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Sudoku Solving Java Program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Sudoku Solving Java Program" Watch "Sudoku Solving Java Program" New topic
Author

Sudoku Solving Java Program

Elliot Penson
Greenhorn

Joined: Dec 29, 2012
Posts: 1
I decided to create a small application to solve a user inputted sudoku puzzle. This class guesses numbers for cells (starting with 1) and then backtracks when a possible number cannot be found. Unfortunately, the program does not work. It seems to fail when it cannot find a correct number. Any help with this program would be greatly appreciated. Also, any tips in general would be really useful. Thanks!

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39550
    
  27
There was a lengthy discussion here: http://www.coderanch.com/t/35387/Programming/SoDuko-puzzle


Ping & DNS - updated with new look and Ping home screen widget
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

I would recommend you read Programming Sudoku by Wei-Meng Lee, if you really want to implement and understand a good solution and perhaps get an idea on how to improve it. The code is written in .NET though, but it will surely provide a good foundation on algorithms you can use to solve it.

Otherwise, if you want to use an existing solution, there are plenty of those around.


The quieter you are, the more you are able to hear.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

"It seems to fail" doesn't really tell us anything. Does it crash/core dump? Does it hang? Does it give bad results?

How do you know it seems to fail? It's not like we can run it ourselves, since we have no idea what input you used. Perhaps you are inputting something that has no solution.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 1945
    
  28
Some time ago I started working on a Sudoko solver which, rather than just solving the puzzle for you, allows you to see how it solves each cell. A beta applet version can be found at http://www.keang.co.uk/sudoku.html.
It has some fairly complex solvers built in but I got bored and so never got around to adding any more solvers or getting the whole thing beyond beta stage. If you want the code let me know and I can upload it to my website.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sudoku Solving Java Program
 
Similar Threads
Exception -- java.lang.StackOverflowError
Sudoku solver help (not brute force)
array out of bounds
SoDuko puzzle
Sudoku Solver