Mind boggling card trick: Difference between revisions

made numerous tidying-up changes, used the word pile instead of pile and stack, clarified what a "red" and "black" pile is (just a name, not the contents), and other small changes. See Paddy3118's talk section for more info.
(Added Perl example)
(made numerous tidying-up changes, used the word pile instead of pile and stack, clarified what a "red" and "black" pile is (just a name, not the contents), and other small changes. See Paddy3118's talk section for more info.)
Line 3:
{{draft task}}
 
Matt Parker of the "Stand Up Maths channel on you tube" has a &nbsp; [https://www.youtube.com/watch?v=aNpGxZ_1KXU <u>YouTube video</u>] &nbsp; of a card trick that creates a semblance of order from chaos.
 
The task is to simulate the trick in a way that mimicksmimics the steps shown in the video.
 
; 1. Cards.
# Create a <code>pack</code>common deck of cards of 52 cards, &nbsp; (which are half red -, half black).
# Give the pack a good shuffle.
; 2. Deal from the randomisedshuffled packdeck, intoyou'll be creating three stackspiles.
# Assemble the cards face down.
## Turn up the &nbsp; ''top card,'' &nbsp; and hold it in your hand.
### if itthe card is &nbsp; black, &nbsp; then add the &nbsp; ''next'' &nbsp; card, (unseen,) to the <code> "black-stack</code>" pile.
### If itthe card is &nbsp; &nbsp; red,&nbsp; &nbsp; then instead add thatthe &nbsp; ''next'' &nbsp; card, (unseen,) to the <code>&nbsp; "red-stack</code>"&nbsp; pile.
## Add the card&nbsp; you''top turnedcard'' over&nbsp; tothat see what colour it was above,you're holding to the <code>'''discard-stack</code>''' pile. <br>&nbsp; (You might optionally show these discarddiscarded cards to giveget an idea of the randomness).
# Repeat the above for the wholerest of the assembledshuffled packdeck.
; 3. SwapChoose the same,a random, number of&nbsp; (call it '''X''') &nbsp; that will be used to swap cards betweenfrom the two"red" and "black" stackspiles.
# Randomly choose the&nbsp; number'''X''' of&nbsp; cards tofrom swapthe &nbsp; "red"&nbsp; pile (unseen), let's call this the &nbsp; "red"&nbsp; bunch.
# Randomly choose that&nbsp; number'''X''' of&nbsp; cards outfrom ofthe each stack to swap. <br> "black" pile (Withoutunseen), knowinglet's thosecall cardsthis -the they could be red or "black" cards from the stacks, we don't know)bunch.
# Put the &nbsp; &nbsp; "red"&nbsp; &nbsp; bunch into the &nbsp; "black" pile.
# Put the &nbsp; "black" &nbsp; bunch into the &nbsp; &nbsp; "red"&nbsp; pile.
# (The above two steps complete the swap of &nbsp; '''X''' &nbsp; cards of the "red" and "black" piles. <br> (Without knowing what those cards are --- they could be red or black, nobody knows).
; 4. Order from randomness?
# CheckVerify (or not) the mathematician's assertion that: '''The number of black cards in the black pile equals the number of red cards in the red pile.'''
<big> '''The number of black cards in the "black" pile equals the number of red cards in the "red" pile.''' </big>
 
 
(Optionally, run this simulation a number of times, gathering more evidence of the truthfulness of the assertion.)
 
Show output on this page.