Perfect shuffle: Difference between revisions

m
used a bigger font so that the colored card indicators (suit and pip) are more easier read, add whitespace before the TOC (table of contents).
(→‎{{header|Python}}: Added a more functional version of the first code example.)
m (used a bigger font so that the colored card indicators (suit and pip) are more easier read, add whitespace before the TOC (table of contents).)
Line 2:
A perfect shuffle (or [https://en.wikipedia.org/wiki/Faro_shuffle faro/weave shuffle]) means splitting a deck of cards into equal halves, and perfectly interleaving them - so that you end up with the first card from the left half, followed by the first card from the right half, and so on:
 
<big>
<!-- START OF DIAGRAM -->
::: <div style="display:inline-block;margin:0.5em 1.5em"><tt><span style="background:#8DF">7♠</span> <span style="background:#8DF">8♠</span> <span style="background:#8DF">9♠</span> <span style="background:#FB5">J♠</span> <span style="background:#FB5">Q♠</span> <span style="background:#FB5">K♠</span></tt></div><div style="display:inline-block">&rarr;<div style="display:inline-block;vertical-align:middle;margin:0.5em 1.5em"><tt><span style="background:#8DF">7♠</span>&nbsp; <span style="background:#8DF">8♠</span>&nbsp; <span style="background:#8DF">9♠</span></tt><br><tt>&nbsp;&nbsp;<span style="background:#FB5">J♠</span>&nbsp; <span style="background:#FB5">Q♠</span>&nbsp; <span style="background:#FB5">K♠</span></tt></div></div><div style="display:inline-block">&rarr;<div style="display:inline-block;vertical-align:middle;margin:0.5em 1.5em"><tt><span style="background:#8DF">7♠</span> <span style="background:#FB5">J♠</span> <span style="background:#8DF">8♠</span> <span style="background:#FB5">Q♠</span> <span style="background:#8DF">9♠</span> <span style="background:#Fb5">K♠</span></tt></div></div>
<!-- END OF DIAGRAM -->
</big>
 
When you repeatedly perform perfect shuffles on an even-sized deck of unique cards, it will at some point arrive back at its original order. How many shuffles this takes, depends solely on the number of cards in the deck - for example for a deck of eight cards it takes three shuffles:
 
<big>
<!-- START OF DIAGRAM -->
::::: {| style="border-spacing:0.5em 0;border-collapse:separate;margin:0 1em;text-align:right"
|-
| <small>''original:''</small> ||
Line 52 ⟶ 55:
|}
<!-- END OF DIAGRAM -->
</big>
 
<p style="font-size:115%; margin:1em 0 0.5em 0">'''''The Task'''''</p>
Line 80 ⟶ 84:
| 10000 || 300
|}
<br><br>
 
=={{header|Ada}}==