Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -

Login

Username

Password

Not registered yet?

Post a reply

Go back

Write your message and submit
:) :| :( :D :o ;) :/ :P :lol: :mad: :rolleyes: :cool: | :dizzy :eek :kiss :roflol :rolleyes :shame :down :up :touched :sleep :wave :swear :tongue :what :faint :dunno
Options

Go back

Topic review (newest first)

Joseluis
2012-03-20 13:01:38

I wrote my own version of an Excel Soduko eatinrr and solver a while back, but I didn't have a good way to generate them until now.  Here's the concept in the alogarithm that you can program yourself.Assuming a 3 3 grid1) Put any random set of numbers in the center box obviously, one each of the digits 1-92) Fill in the box above and below the center box with any random number of choice that doesn't break the Soduko rule.3) Keep track of all of the options for each cell and give priority to assigning that random number to the CELL THAT HAS THE LEAST OPTIONS AVAILABLE TO IT.  In other words .Each cell has 9 optional digits that the cell can contain.  As you enter a value in a cell, the cells in the same box, row and column no longer have that digit as an option.  Take that option away from all other cells in the box, row and column.  They now only have 8 possible entries.  As you continue with this process, you will see that some cells may have five options left while other cells have only 3 options.  Provide a random number (that is within the available options for that cell) to the cells with less options first.4) Providing a random number in the top box and then the bottom box and then repeating seems to keep the random generation working smoothly.5) Once all cells are completed in the center column of boxes, move to either the left or right and complete all cells in column of boxes.6) To complete the cells in the left or right columns, simply apply one random number (again, within the remaining possible values) for each cell.  Give priority to cells that have the least number of options.  Try scanning the whole column of boxes and looking for cells with only one option left.  Be sure to do those first.7) Complete the last column of boxes and assign values to the cells in the same way.WORKS EVERY TIME IF YOU APPLY THE LOGIC

bobbym
2011-10-08 01:14:23

No, no, no, each box is calculated. It does not matter how. Brute force is a method calculation. Find the routine that fills the boxes with numbers. Insert at its end whatever command pauses and allows you to examine the contents of the variable at that point. This is how it is done.

anonimnystefy
2011-10-08 01:11:53

how do you mean calculate.it is a brute-force algorithm,nothing is calculated.

bobbym
2011-10-08 01:10:11

Put a stop command or a break command  or a pause command at the end of the routine that calculates the boxes. Then it pause after every box is calculated. Either you must do it manually by inserting the appropriate command or use your debugger.

anonimnystefy
2011-10-08 01:08:05

well,i don't know if i will get to it very fast.when it finds a number that can be in a box it moves the next empty box,and tries values for it,and again and again until it all fills up or it finds a box that no number can go into.in the second case it goes to the square it filled up before the one where 'no number can stand' and it tries the next possible value.

bobbym
2011-10-08 01:03:56

That is row 1, column 3?

If so run the program to where that number is computed. There you will find the logic error.

anonimnystefy
2011-10-08 01:02:38

the third one.

bobbym
2011-10-08 01:01:19

Oh, okay.

Which is the first box that has a wrong number in it?

anonimnystefy
2011-10-08 00:59:47

i do have the final answer.i got the example from a Sudoku book.it has solutions in the back.

bobbym
2011-10-08 00:56:43

How can you check what is supposed to be in the answer if you do not know what the answer is?

anonimnystefy
2011-10-08 00:54:46

i think i don't understand what you mean...actually i know i don't understand what you mean.

bobbym
2011-10-08 00:47:17

No, I meant for the purpose of checking what each box is supposed to hold.

anonimnystefy
2011-10-08 00:45:42

hi

all rows are obviously wrong,which means that the columns and squares are obviously wrong.don't you think i already know that?isn't it obvious.i told you that there is  problem around nines.

nah,i want it to put out a random matrix that will have the elements that i have put in but that it has a lot of nines...of course i do.that's why it is called Sudoku_solver. smile

bobbym
2011-10-08 00:41:42

Hi;

No problem. The first row is obviously wrong. Too many nines! Each row has that problem.
You can start there. Do you want the answer to that sudoku?

anonimnystefy
2011-10-08 00:36:24

hi bobbym

i had to go to sleep sleep

for example if i put in:
0 2 0 0 0 9 1 4 6
9 0 6 8 0 0 0 0 2
0 5 0 6 0 0 9 0 0
0 0 0 4 9 0 7 0 0
0 0 5 7 6 8 4 0 0
0 0 3 0 2 1 0 0 0
0 0 8 0 0 4 0 9 0
7 0 0 0 0 5 2 0 4
2 4 1 9 0 0 0 3 0

it puts out:
8 2 9 9 9 9 1 4 6
9 1 6 8 4 9 9 9 2
3 5 4 6 1 2 9 7 8
6 9 9 4 9 9 7 9 9
9 9 5 7 6 8 4 1 3
4 7 3 5 2 1 8 9 9
5 6 8 9 9 4 9 9 9
7 9 9 1 3 5 2 6 4
2 4 1 9 8 9 9 3 9

Board footer

Powered by FluxBB