Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Sudoku

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    26
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Sudoku

    Can anyone help me on this??
    Write the pseudocode of the algorithm that does the following:

    * it takes a 9x9 matrix filled with numbers from 0 to 9: 0s stand for a missing sudoku number (a number to be determined), other numbers (from 1 to 9) stand for numbers that are given (corresponding to the numbers that appear on the grid of your book of sudoku when you do it on paper).

    * it returns a 9x9 grid filled with numbers from 1 to 9 in such a way that the numbers meet the constraints of sudoku.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Sudoku

    Google turns up a lot of code for sudoku solvers, so I encourage you to look into it. But to start with, you need to write a few methods to solve the puzzle based upon the rules. One method can check for entries based upon row/column/box exclusions which only allow a single number in the cell (eg you have 123450789 - you can obviously fill in 6). Another method can fill in the grid based upon the process of elimination (surrounding rows, columns, and boxes restrict the value of a certain cell - here you can calculate the possible value for each cell and only one possibility allows you to set its value). A third method can be used if neither of the two above methods sets a value, this method seeds the puzzle then lets the other methods proceed - this method should be able to backtrack should the puzzle not be solveable based upon its 'seed'.

  3. The Following User Says Thank You to copeg For This Useful Post:

    JavaPF (December 1st, 2009)

Similar Threads

  1. Sudoku Solver
    By MysticDeath in forum Java Theory & Questions
    Replies: 5
    Last Post: September 19th, 2009, 09:33 PM
  2. Mini Sudoku game 4x4 ( four 2x2 grids) program
    By derky in forum What's Wrong With My Code?
    Replies: 6
    Last Post: September 16th, 2009, 07:39 AM