Anonymous user
24 game/Solve: Difference between revisions
→{{header|Tcl}}: Make the code only report the first solution by default
(→{{header|Tcl}}: add some comments) |
(→{{header|Tcl}}: Make the code only report the first solution by default) |
||
Line 200:
{A d B a C b D c}
}
set stopAtFirst 1
proc findSolution {values} {
global patterns permutations stopAtFirst
set found 0
# For each possible structure with numbers at the leaves...
Line 224 ⟶ 225:
if {[expr $e] == 24.0} {
puts [string map {.0 {}} $e]
if {$stopAtFirst} return
incr found
}
Line 241 ⟶ 243:
Demonstrating it in use:
<pre>$ tclsh8.4 24player.tcl 3 2 8 9
((9 - 3) * 8) / 2</pre>
|