# Checker Program

• November 13th, 2012, 07:15 PM
maxreed
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.
• November 13th, 2012, 09:02 PM
copeg
Re: Checker Program
Quote:

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?
• November 13th, 2012, 09:30 PM
maxreed
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.
• November 13th, 2012, 11:08 PM
jps
Re: Checker Program
Quote:

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...
• November 13th, 2012, 11:58 PM
pbrockway2
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.
• November 14th, 2012, 08:41 AM
maxreed
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")
• November 14th, 2012, 04:58 PM
jps
Re: Checker Program
So is this checkers or sudoku?

Quote:

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.