Combinations with repetitions: Difference between revisions

Line 2,756:
 
 
<lang Quackery>( nextplain generates the next plaindrome in the
the current base by adding one to a given plaindrome,
plaindrome, then replacing each trailing zero with the least
significant non-zero withdigit of the least significant non-zeronumber
digit of the number
See: https://oeis.org/search?q=plaindromes
Line 2,774 ⟶ 2,773:
prints "0 1 2 3 11 12 13 22 23 33"
i.e. decimal "0 1 2 3 5 6 7 10 11 15"
 
Right padding the base 4 representations with
with zeros gives all the combinations with repetitions
with repetitions for selecting two doughnuts in a store selling
four types of doughnut, numbered 0, 1, 2, and 3.
doughnuts in a store selling four types
of doughnut, numbered 0, 1, 2, and 3.
00 01 02 03 11 12 13 22 23 33 )
[ 1+ dup 0 = if done
Line 2,790 ⟶ 2,788:
again ]
swap rot 1+ times
[ base share * over + ]
nip ] is nextplain ( n --> n )
over + ]
nip ] is nextplain ( n --> n )
[ dup base put
Line 2,803 ⟶ 2,800:
again ]
base release
2drop ] is kcombnums ( n n --> [ )
 
[ [] unrot times
$ "jam iced plain" nest$
[ base share /mod
temp put
rot join swap ]
2 3 kcombnums
drop ] is ndigits ( n n --> [ )
 
[ [] unrot
witheach
[ 2dip timesdup peek
nested rot [swap 3join /mod
temp share swap ]
drop ] peek echo$ sp is [peek] ( [ [ --> [ )
 
drop cr ]
[ dup temp releaseput
size dup base put
2 3 dip dup kcombnums
[] unrot witheach
[ over ndigits
temp share swap [peek]
nested rot swap join
over +swap ]
temp putrelease
base release
drop ] is kcombs ( n [ --> [ )
 
2
$ "jam iced plain" nest$
kcombs
witheach
[ witheach
drop[ echo$ sp ] cr ]
cr
3 10 kcombnums size echo</lang>
1,462

edits