Combinations with repetitions: Difference between revisions
→{{header|Quackery}}: refactored
(→{{header|Quackery}}: refactored) |
|||
Line 2,756:
<lang Quackery>( nextplain generates the next plaindrome in the
significant non-zero
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
four types of doughnut, numbered 0, 1, 2, and 3.▼
▲ 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
[
nested rot
drop ]
drop cr ] ▼
[ dup temp
size dup base put
[] unrot witheach
[ over ndigits
temp share swap [peek]
nested rot swap join
base release
drop ] is kcombs ( n [ --> [ )
2
▲ $ "jam iced plain" nest$
kcombs
witheach
[ witheach
cr
3 10 kcombnums size echo</lang>
|