Thread: sudoku
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Henry[_5_] Henry[_5_] is offline
external usenet poster
 
Posts: 104
Default sudoku

Wim,

Are you trying to make a Sudoku puzzle or to solve one?

Either way, put the numbers 1 to 9 in a string (in any order)
If the number is already used, take it out of the string.
Then choose a random position from the string
MyNum = Rand *Len(string)

Mid(string,MyNum,1)

Do your checks to see if that number is possible in that position, if it is
then use the number.

Now that the number has been used, take it out of the string

String = Left(string,Mynum-1) & Right(string,Len(string)-Mynum).

You are now left with the remaining, unused numbers to select from.

Henry


"Wim Rijsdijk" wrote in message
. ..
forget this one, I made a new message, without Excel-sheet
!!!!!!!!!!!!!!!!!!!!!!!!

"Wim Rijsdijk" schreef in bericht
...
Hello,

I am trying to make an Excel-spreadsheet, based on Sudoku puzzle.

So , cells a1 to i1 have to be filled with the numbers 1 to 9, in
random
order.


a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s

1


4


6




1
2
3

5

7
8
9

2

1

2
5
9

4
6



3



7
8


3








7

1
2
3
4
5
6

8
9

4


1
3
9


7
2




4
5
6

8


5

3


7


5


1
2

4

6

8
9

6
9
7


4





1
2
3

5
6

8


7
8
9


2

6

4

1

3

5

7



8
1
2

4
6
7

8




3

5



9

9



9
8





1
2
3
4
5
6
7





As you see, a1 to i1 is only filled with 4 and 6.
In columns k to s you can see which numbers are not used, so in this

example
in row 1, it is 1,2,3,5,7,8,9

The problem is, I want a formula to put on k1, with the following needs:
- check for a1 to i1 if number 1 is on it. In this example NO.
- if NO, then on k1 the number 1 has to appear
- it YES, then on k1 the number 1 has to disappear.

if((b1:j1)=1;" ";"1") is not working. What is the solution ?!?!?!?

If I have 1 formula, I can fill the other cells.

Thanks in advance, for helping me.

Greets,
Wim Rijsdijk