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 7 of 7

Thread: Checker Program

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Checker Program

    I am trying to create a checker program(for a sudoku puzzle) that will read a completed board and then go to determine if it obeys the constraints. If it does, it just says so, if it doesn't it reports the conflict. Where should I start? Thanks.

    every row includes the numbers 1 through 9
    every column includes the number 1 through 9
    every 3x3 square(box) includes each number 1 through 9

    It will read in a complete board (txt file)
    3
    4 9 8 1 3 6 5 2 7
    3 1 5 9 2 7 8 6 4
    7 2 6 5 8 4 1 3 9
    1 7 4 2 5 9 6 8 3
    5 8 9 7 6 3 4 1 2
    2 6 3 4 1 8 9 7 5
    8 5 1 6 7 2 3 5 8
    9 4 7 3 9 1 2 4 6
    6 3 2 8 4 5 7 9 1

    Then based on the previous listed features it will determine if it will work, if not then it will tell us the issue.


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

    Default Re: Checker Program

    Where should I start?
    Break the problem down into individual problems as small as possible. Do you know how to read a file? Do you have an algorithm? Are you using a GUI? Command line? How will you notify the user?

  3. #3
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Checker Program

    File read in is done. Algorithm is where I need help. No GUI. It takes a single input fi le as a command-line parameter. The console is where the user will be notified. So basically, the algorithm is where I am stuck. I think I will have to create an algorithm for the row, column, and box to verify that none of the constraints are being broken.

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Checker Program

    I think I will have to create an algorithm for the row, column, and box to verify that none of the constraints are being broken.
    go on...

  5. #5
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Checker Program

    So, what is the algorithm?

    What I mean is, if you were confronted with an array of numbers how would you determine whether it were a valid sudoko solution? Once you can expkain it in ordinary language, the code is straight forward. But the algorithm (process/description/plan of attack) comes first.

    --- Update ---

    So, what is the algorithm?

    What I mean is, if you were confronted with an array of numbers how would you determine whether it were a valid sudoko solution? Once you can expkain it in ordinary language, the code is straight forward. But the algorithm (process/description/plan of attack) comes first.

  6. #6
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Checker Program

    I am having trouble taking the text file and storing it in an 2-d array (9x9). How would I do that ( I know how to do it manually but not by looping it to look like a 9x9 grid)? Once I know that I can just check for distinct values in the rows, distinct values in the columns and then for duplicates in that array to verify that the puzzle is correct.

    pseudocode
    for(i=0;i<9;i++){ //row
    maybe an arraylist of horizontals
    for(j=0;j<9;j++){ // columns
    //check for distinct row value
    if(the arraylist of horizontals does not contain something?)
    System.out.println("no distinct num")

  7. #7
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Checker Program

    So is this checkers or sudoku?

    How would I do that
    pseudocode
    for(i=0;i<9;i++){ //row
    maybe an arraylist of horizontals
    for(j=0;j<9;j++){ // columns
    //check for distinct row value
    if(the arraylist of horizontals does not contain something?)
    System.out.println("no distinct num")
    what happened when you tried it? Does it solve the problem?
    Are the first 9 in the top row? Second 9 in the second row? last 9 end up in the last row? If all 3 are yes then it seems right so far.

    Looks to me like the only thing you are missing is the confidence to move forward.

Similar Threads

  1. how to add Spell checker
    By hope2012 in forum Java Theory & Questions
    Replies: 1
    Last Post: November 8th, 2012, 08:23 AM
  2. Spell checker using bags
    By kovynjd2010 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 16th, 2012, 12:09 PM
  3. Need switch statement for checker game (DUE TOMORROW!)
    By strengthonor in forum Loops & Control Statements
    Replies: 1
    Last Post: September 16th, 2011, 03:40 AM
  4. Magic Square Checker
    By Hypnos in forum Object Oriented Programming
    Replies: 1
    Last Post: April 3rd, 2011, 06:37 PM
  5. Password Strength Checker
    By uthuth in forum Object Oriented Programming
    Replies: 1
    Last Post: February 6th, 2010, 04:09 PM

Tags for this Thread