Perfect shuffle: Difference between revisions
Added Quackery.
(Added Quackery.) |
|||
Line 1,870:
#print(n, mul_ord2(n))
print(n, shuffles(n))</lang>
=={{header|Quackery}}==
<lang Quackery> [ [] swap
times [ i^ join ] ] is deck ( n --> [ )
[ [] swap
dup size 2 / split
dup size times
[ behead
dip [ swap behead ]
2 pack
dip rot join
unrot swap ]
2drop ] is weave ( [ --> [ )
[ deck dup
0 temp put
[ 1 temp tally
weave 2dup = until ]
2drop
temp take ] is shuffles ( n --> n )
' [ 8 24 52 100 1020 1024 10000 ]
witheach
[ say "A deck of "
dup echo say " cards needs "
shuffles echo say " shuffles."
cr ]</lang>
{{Out}}
<pre>A deck of 8 cards needs 3 shuffles.
A deck of 24 cards needs 11 shuffles.
A deck of 52 cards needs 8 shuffles.
A deck of 100 cards needs 30 shuffles.
A deck of 1020 cards needs 1018 shuffles.
A deck of 1024 cards needs 10 shuffles.
A deck of 10000 cards needs 300 shuffles.
</pre>
=={{header|R}}==
|