June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,18 @@
USING: continuations grouping io kernel math math.combinatorics
prettyprint quotations random sequences sequences.deep ;
IN: rosetta-code.24-game
: 4digits ( -- seq ) 4 9 random-integers [ 1 + ] map ;
: expressions ( digits -- exprs )
all-permutations [ [ + - * / ] 3 selections
[ append ] with map ] map flatten 7 group ;
: 24= ( exprs -- )
>quotation dup call( -- x ) 24 = [ . ] [ drop ] if ;
: 24-game ( -- )
4digits dup "The numbers: " write . "The solutions: "
print expressions [ [ 24= ] [ 2drop ] recover ] each ;
24-game