Set puzzle: Difference between revisions
Content added Content deleted
Walterpachl (talk | contribs) m (→{{header|REXX}}: it's -> its) |
m (moved Categorys to top) |
||
Line 2,113: | Line 2,113: | ||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
The principle behind this code is that the space of possible solutions is a substantial proportion of the space of possible hands, so picking a random hand and verifying that it is a solution, repeating until that verification succeeds, is a much quicker way to find a solution than a systematic search. |
The principle behind this code is that the space of possible solutions is a substantial proportion of the space of possible hands, so picking a random hand and verifying that it is a solution, repeating until that verification succeeds, is a much quicker way to find a solution than a systematic search. |
||
It also makes the code substantially simpler. |
|||
<lang tcl># Generate random integer uniformly on range [0..$n-1] |
<lang tcl># Generate random integer uniformly on range [0..$n-1] |
||
proc random n {expr {int(rand() * $n)}} |
proc random n {expr {int(rand() * $n)}} |
||
Line 2,294: | Line 2,295: | ||
(red,squiggle,two,open) |
(red,squiggle,two,open) |
||
</pre> |
</pre> |
||
{{omit from|GUISS}} |
|||
[[Category:Cards]] |
|||
[[Category:Puzzles]] |