Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Soduko
Message
 
To
13/06/2006 03:03:41
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Re: Soduko
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01073278
Message ID:
01128642
Views:
27
Walter, thanks.

>Yuri,
>
>>This thread invoked my interest to the issue. Take a look on Download # 30434. If you do not mind, it will contain your code, otherwise I will add something on my own. Let me know.
>>If you have ideas about how to code the puzzle with single solution and/or define the difficulty level, I would greatly appreciate if you share it with me.
>
>I wrote this thing only one day or so after I ever heard about sodoku. I don't think it is very solid as there is one big flaw in it that it does not create a truly randomized puzzle.
>
>As far as for the difficulty level, I guess it has to do with the number of numbers you show on the puzzle combined with which numbers.
>
>I wrote a VFP program to solve a puzzle a few months ago, That program could be enhanced to determine the difficulty level.
>
>But anyways, I'm afraid I can't help you right now: I'm too busy with other things..
>
>Walter,
>
>
>>
>>>How about this one.
>>>
>>>It will create a new sudoko (never heard about it until today though) map each time.
>>>
>>>
>>>DIMENSION aStrings[9], aResult[9], aRandomize[6,3]
>>>CLEAR
>>>
>>>FOR nT = 0 TO 17
>>>	aRandomize[nT+1] = VAL(SUBSTR(GETWORDNUM("123 132 231 213 312 321", INT(nT/3)+1),(nT%3)+1,1))
>>>ENDFOR
>>>
>>>* Generate a random number to use as a base
>>>cString = "123456789"
>>>FOR nT = 1 TO 9
>>>	nPos = INT(RAND() * 9)+1
>>>	cString = IIF(nPos>1, SUBSTR(cString, nPos,1)+LEFT(cString, nPos-1)+SUBSTR(cString,nPos+1), cString)
>>>	cString =  SUBSTR(cString,2)+LEFT(cString,1)
>>>ENDFOR
>>>
>>>* Make a basic Soduko map
>>>nT = 1
>>>FOR nY = 1 TO 3
>>>	FOR nX = 1 TO 3
>>>		aStrings[nT] = cString
>>>		cString = SUBSTR(cString,4)+LEFT(cString,3)
>>>		nT = nT + 1
>>>	ENDFOR
>>>	cString =  SUBSTR(cString,2)+LEFT(cString,1)
>>>ENDFOR
>>>
>>>* Move rows arround, to randomize
>>>nT = 1
>>>nRand2 = INT(RAND()*6)+1
>>>FOR nY = 1 TO 3
>>>	nRand = INT(RAND()*6)+1
>>>	FOR nY2 = 1 TO 3
>>>		aResult[nT] = aStrings[(aRandomize[nRand2, nY]-1)*3+aRandomize[nRand, nY2]]
>>>		nT = nT + 1
>>>	ENDFOR
>>>ENDFOR
>>>
>>>* Move columns arround, to randomize
>>>nT = 1
>>>nRand2 = INT(RAND()*6)+1
>>>FOR nX = 1 TO 3
>>>	nRand = INT(RAND()*6)+1
>>>	FOR nX2 = 1 TO 3
>>>		FOR nX3 = 1 TO 9
>>>			aStrings[nX3] = STUFF(aStrings[nx3], (aRandomize[nRand2, nX]-1)*3+aRandomize[nRand, nX2], 1, ;
>>>				SUBSTR(aResult[nX3], nT,1))
>>>		ENDFOR
>>>		nT = nT + 1
>>>	ENDFOR
>>>ENDFOR
>>>
>>>* Display puzzle
>>>
>>>FOR nT = 1 TO 9
>>>	? " "+aStrings[nT]
>>>ENDFOR
Previous
Reply
Map
View

Click here to load this message in the networking platform