all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1,24 @@
require 'stats/base'
Number=: ;:'one two three'
Colour=: ;:'red green purple'
Fill=: ;:'solid open striped'
Symbol=: ;:'oval squiggle diamond'
Features=: Number ; Colour ; Fill ;< Symbol
Deck=: > ; <"1 { i.@#&.> Features
sayCards=: (', ' joinstring Features {&>~ ])"1
drawRandom=: ] {~ (? #)
isSet=: *./@:(1 3 e.~ [: #@~."1 |:)"2
getSets=: ([: (] #~ isSet) ] {~ 3 comb #)
countSets=: #@:getSets
set_puzzle=: verb define
target=. <. -: y
whilst. target ~: countSets Hand do.
Hand=. y drawRandom Deck
end.
echo 'Dealt ',(": y),' Cards:'
echo sayCards Hand
echo 'Found ',(":target),' Sets:'
echo sayCards getSets Hand
)

View file

@ -0,0 +1,27 @@
set_puzzle 9
Dealt 9 Cards:
three, purple, open, oval
three, green, open, diamond
three, red, solid, squiggle
three, green, solid, oval
three, purple, striped, oval
three, red, open, oval
one, red, solid, oval
one, green, open, squiggle
two, purple, striped, squiggle
Found 4 Sets:
three, green, open, diamond
three, red, solid, squiggle
three, purple, striped, oval
three, green, open, diamond
one, red, solid, oval
two, purple, striped, squiggle
three, red, solid, squiggle
one, green, open, squiggle
two, purple, striped, squiggle
three, green, solid, oval
three, purple, striped, oval
three, red, open, oval