0

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.

3
Contributors
9
Replies
10
Views
5 Years
Discussion Span
Last Post by FUTURECompEng
0

Start by making a list of the features the program should have. For example: what input does it get and what does it do with that input.

0

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.

0

That is what I need help with. I am using sat4j to solve the puzzle, but to verify that it actually is a solvable puzzle do I need to use sat4j to do that too?

0

No problem I am slowly figuring it out. Can you however help me take a text file and store it into a 2d array? I have an incomplete Sudoku puzzle and I want be able to store the filled in numbers and -'s into the 2d array.

Attachments
3
4 - - 1 - - - 2 -
3 1 - 9 - 7 8 6 -
- - 6 - - 4 - 3 -
- - 4 - 5 - - 8 3
- 8 - 7 - 3 - 1 -
2 6 - 4 - - 9 - -
- 4 - 6 - - 3 - -
- 5 7 3 - 1 - 4 6
- 3 - - - 5 - - 1
0

What are the steps for doing that?

What NormR1 is saying that you need to think through each step you take when you try to solve a sodoku. The write down each step in it's simplest terms e.g. "Look at row" -> "does row contain each number 1 - 9?" etc etc

Then most importantly...WRITE YOUR STEPS DOWN!

This makes is much easier to program

0

Can you describe what is in the txt file and where its contents would go in the 2D array?
One approach would be to read a line from the file, parse the tokens on the line into separate items/tokens and store each item in the columns of a row in the array. Each line's tokens would be stored in the columns of a row.

I define a 2D array as having rows and columns like this: anArray[theRows][thecolumns]

0

In the text file is an example of a complete Sudoku puzzle and I need to make sure that the puzzle follows the constraints. I think the best way to do this would be to use the 2d array to compare the rows and columns by varifying if the numbers duplicate.
I will work on your suggestion, by parsing the tokens.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.