Anonymous user
Set puzzle: Difference between revisions
→{{header|Tailspin}}: Corrected a mistake in the program
(→{{header|Tailspin}}: Corrected a mistake in the program) |
|||
Line 3,607:
=={{header|Tailspin}}==
Dealing cards at random to the size of the desired hand, then trying again if the desired set count is not achieved
<lang tailspin>
def deck: [ 1..3 -> (def colour: $;
Line 3,633:
templates findSets
def hand: $;
[ 1..$hand::length -
$a+1..$hand::length -
$b+1..$hand::length
) !
) -> isSet ] !
Line 3,644:
def nSets: $(2);
{} -> #
<{sets: <[]($nSets..)>}> $ !
<>
def hand: $nCards -> deal;
Line 3,667:
end formatSets
[9,
</lang>
{{out}}
<pre>
hand:
green-
purple-squiggle-
red-oval-
purple-diamond-
red-
purple-diamond-two-open
sets:
[ green-
[
[ green-
[ green-oval-three-striped red-diamond-three-striped purple-squiggle-three-striped ]
</pre>
<pre>
[12,6] -> setPuzzle -> formatSets -> !OUT::write
|