• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sudoku Solving Java Program

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There was a lengthy discussion here: https://coderanch.com/t/35387/Programming/SoDuko-puzzle
 
Bartender
Posts: 825
5
Python Ruby Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic