Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
56
Task/Set-puzzle/Tailspin/set-puzzle-1.tailspin
Normal file
56
Task/Set-puzzle/Tailspin/set-puzzle-1.tailspin
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
def deck: [ { by 1..3 -> (colour: $),
|
||||
by 1..3 -> (symbol: $),
|
||||
by 1..3 -> (number: $),
|
||||
by 1..3 -> (shading: $)}
|
||||
];
|
||||
|
||||
templates deal
|
||||
@: $deck;
|
||||
[ 1..$ -> \($@deal::length -> SYS::randomInt -> ^@deal($ + 1) !\)] !
|
||||
end deal
|
||||
|
||||
templates isSet
|
||||
def set : $;
|
||||
[ $(1).colour::raw + $(2).colour::raw + $(3).colour::raw, $(1).symbol::raw + $(2).symbol::raw + $(3).symbol::raw,
|
||||
$(1).number::raw + $(2).number::raw + $(3).number::raw, $(1).shading::raw + $(2).shading::raw + $(3).shading::raw ] -> #
|
||||
// if it is an array where all elements of 3, 6 or 9, it is a set
|
||||
when <[<=3|=6|=9>+ VOID]> do $set !
|
||||
end isSet
|
||||
|
||||
templates findSets
|
||||
def hand: $;
|
||||
[ 1..$hand::length - 2 -> \(def a: $;
|
||||
$a+1..$hand::length - 1 -> \(def b: $;
|
||||
$b+1..$hand::length -> $hand([$a, $b, $]) !
|
||||
\) !
|
||||
\) -> isSet ] !
|
||||
end findSets
|
||||
|
||||
templates setPuzzle
|
||||
def nCards: $(1);
|
||||
def nSets: $(2);
|
||||
{sets: []} -> #
|
||||
when <{sets: <[]($nSets..)>}> do $ !
|
||||
otherwise
|
||||
def hand: $nCards -> deal;
|
||||
{hand: $hand, sets: $hand -> findSets} -> #
|
||||
end setPuzzle
|
||||
|
||||
templates formatCard
|
||||
def colours: colour´1:['red', 'green', 'purple'];
|
||||
def symbols: symbol´1:['oval', 'squiggle', 'diamond'];
|
||||
def numbers: number´1:['one', 'two', 'three'];
|
||||
def shadings: shading´1:['solid', 'open', 'striped'];
|
||||
$ -> '$colours($.colour);-$symbols($.symbol);-$numbers($.number);-$shadings($.shading);' !
|
||||
end formatCard
|
||||
|
||||
templates formatSets
|
||||
$ -> 'hand:
|
||||
$.hand... -> '$ -> formatCard;
|
||||
';
|
||||
sets:
|
||||
$.sets... -> '[$... -> ' $ -> formatCard; ';]
|
||||
';' !
|
||||
end formatSets
|
||||
|
||||
[9,4] -> setPuzzle -> formatSets -> !OUT::write
|
||||
1
Task/Set-puzzle/Tailspin/set-puzzle-2.tailspin
Normal file
1
Task/Set-puzzle/Tailspin/set-puzzle-2.tailspin
Normal file
|
|
@ -0,0 +1 @@
|
|||
[12,6] -> setPuzzle -> formatSets -> !OUT::write
|
||||
Loading…
Add table
Add a link
Reference in a new issue