Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
48
Task/Combinations/Quackery/combinations-1.quackery
Normal file
48
Task/Combinations/Quackery/combinations-1.quackery
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
[ 0 swap
|
||||
[ dup 0 != while
|
||||
dup 1 & if
|
||||
[ dip 1+ ]
|
||||
1 >> again ]
|
||||
drop ] is bits ( n --> n )
|
||||
|
||||
[ [] unrot
|
||||
bit times
|
||||
[ i bits
|
||||
over = if
|
||||
[ dip
|
||||
[ i join ] ] ]
|
||||
drop ] is combnums ( n n --> [ )
|
||||
|
||||
[ [] 0 rot
|
||||
[ dup 0 != while
|
||||
dup 1 & if
|
||||
[ dip
|
||||
[ dup dip join ] ]
|
||||
dip 1+
|
||||
1 >>
|
||||
again ]
|
||||
2drop ] is makecomb ( n --> [ )
|
||||
|
||||
[ over 0 = iff
|
||||
[ 2drop [] ] done
|
||||
combnums
|
||||
[] swap witheach
|
||||
[ makecomb
|
||||
nested join ] ] is comb ( n n --> [ )
|
||||
|
||||
[ behead swap witheach max ] is largest ( [ --> n )
|
||||
|
||||
[ 0 rot witheach
|
||||
[ [ dip [ over * ] ] + ]
|
||||
nip ] is comborder ( [ n --> n )
|
||||
|
||||
[ dup [] != while
|
||||
sortwith
|
||||
[ 2dup join
|
||||
largest 1+ dup dip
|
||||
[ comborder swap ]
|
||||
comborder < ] ] is sortcombs ( [ --> [ )
|
||||
|
||||
3 5 comb
|
||||
sortcombs
|
||||
witheach [ witheach [ echo sp ] cr ]
|
||||
31
Task/Combinations/Quackery/combinations-2.quackery
Normal file
31
Task/Combinations/Quackery/combinations-2.quackery
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
[ stack ] is comb.stack
|
||||
[ stack ] is comb.items
|
||||
[ stack ] is comb.required
|
||||
[ stack ] is comb.result
|
||||
|
||||
[ 1 - comb.items put
|
||||
1+ comb.required put
|
||||
0 comb.stack put
|
||||
[] comb.result put
|
||||
[ comb.required share
|
||||
comb.stack size = if
|
||||
[ comb.result take
|
||||
comb.stack behead
|
||||
drop nested join
|
||||
comb.result put ]
|
||||
comb.stack take
|
||||
dup comb.items share
|
||||
= iff
|
||||
[ drop
|
||||
comb.stack size 1 > iff
|
||||
[ 1 comb.stack tally ] ]
|
||||
else
|
||||
[ dup comb.stack put
|
||||
1+ comb.stack put ]
|
||||
comb.stack size 1 = until ]
|
||||
comb.items release
|
||||
comb.required release
|
||||
comb.result take ] is comb ( n n --> )
|
||||
|
||||
3 5 comb
|
||||
witheach [ witheach [ echo sp ] cr ]
|
||||
16
Task/Combinations/Quackery/combinations-3.quackery
Normal file
16
Task/Combinations/Quackery/combinations-3.quackery
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[ dup size dip
|
||||
[ witheach
|
||||
[ over swap peek swap ] ]
|
||||
nip pack ] is arrange ( [ [ --> [ )
|
||||
|
||||
' [ 10 20 30 40 50 ]
|
||||
3 5 comb
|
||||
witheach
|
||||
[ dip dup arrange
|
||||
witheach [ echo sp ]
|
||||
cr ]
|
||||
drop
|
||||
cr
|
||||
$ "zero one two three four" nest$
|
||||
' [ 4 3 1 0 1 4 3 ] arrange
|
||||
witheach [ echo$ sp ]
|
||||
Loading…
Add table
Add a link
Reference in a new issue