Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
64
Task/24-game-Solve/Quackery/24-game-solve.quackery
Normal file
64
Task/24-game-Solve/Quackery/24-game-solve.quackery
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
[ ' [ 0 1 2 3 ]
|
||||
permutations ] constant is numorders ( --> [ )
|
||||
|
||||
[ []
|
||||
4 3 ** times
|
||||
[ [] i^
|
||||
3 times
|
||||
[ 4 /mod 4 +
|
||||
rot join swap ]
|
||||
drop
|
||||
nested join ] ] constant is oporders ( --> [ )
|
||||
|
||||
[ [] numorders witheach
|
||||
[ oporders witheach
|
||||
[ dip dup join nested
|
||||
rot swap join swap ]
|
||||
drop ] ] constant is allorders ( --> [ )
|
||||
|
||||
[ [] unrot witheach
|
||||
[ dip dup peek
|
||||
swap dip [ nested join ] ]
|
||||
drop ] is reorder ( [ [ --> [ )
|
||||
|
||||
[ ' [ [ 0 1 4 2 5 3 6 ]
|
||||
[ 0 1 4 2 3 5 6 ]
|
||||
[ 0 1 2 4 3 5 6 ] ]
|
||||
witheach
|
||||
[ dip dup reorder swap ]
|
||||
4 pack ] is orderings ( [ --> [ )
|
||||
|
||||
[ witheach
|
||||
[ dup number? iff n->v done
|
||||
dup ' + = iff
|
||||
[ drop v+ ] done
|
||||
dup ' - = iff
|
||||
[ drop v- ] done
|
||||
' * = iff v* done
|
||||
v/ ]
|
||||
24 n->v v- v0= ] is 24= ( [ --> b )
|
||||
|
||||
[ 4 pack sort
|
||||
[] swap
|
||||
' [ + - * / ] join
|
||||
allorders witheach
|
||||
[ dip dup reorder orderings
|
||||
witheach
|
||||
[ dup 24= iff
|
||||
[ rot swap
|
||||
nested join swap ]
|
||||
else drop ] ]
|
||||
drop
|
||||
uniquewith
|
||||
[ dip unbuild unbuild $> ]
|
||||
dup size
|
||||
dup 0 = iff
|
||||
[ 2drop say "No solutions." ]
|
||||
done
|
||||
dup 1 = iff
|
||||
[ drop say "1 solution." ]
|
||||
else
|
||||
[ echo say " solutions." ]
|
||||
unbuild
|
||||
2 split nip
|
||||
-2 split drop nest$ 90 wrap$ ] is solve ( n n n n --> )
|
||||
Loading…
Add table
Add a link
Reference in a new issue