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.

Recommended Answers

All 9 Replies

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.

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.

it will determine if it will work

What are the steps for doing that?

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?

I know nothing about sat4j.

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.

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

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]

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.