48 lines
1 KiB
Text
48 lines
1 KiB
Text
[ 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 ]
|