24 game: Difference between revisions

520 bytes added ,  25 days ago
Added Frink
(Added Frink)
Line 5,836:
 
</pre>
 
alldigits=array[1 to 9]
 
chosen = new array
for n = 0 to 3
chosen@n = random[alldigits]
 
println[chosen]
 
ops = ["+", "-", "*", "/"]
for d = chosen.lexicographicPermute[]
multifor o = [ops, ops, ops]
{
str = "((" + d@0 + o@0 + d@1 + ")" + o@1 + d@2 + ")" + o@2 + d@3
if eval[str] == 24
println[str]
}</syntaxhighlight>
{{out}}
<pre>
[4, 3, 1, 4]
((1*4)+4)*3
((3-1)+4)*4
((3+4)-1)*4
((4-1)+3)*4
((4*1)+4)*3
((4/1)+4)*3
((4+3)-1)*4
((4+4)*1)*3
((4+4)/1)*3
((4+4)*3)*1
((4+4)*3)/1
</pre>
 
 
=={{header|FutureBasic}}==
494

edits