Bamboo Survival Shelter, Stream Fishing, Catch and Cook: Survival Alone | EP.242

Stand-up Maths
22 followers
9 Video Views·Aug 9, 2023
Famously, in magic, the holy grail of card tricks is an effect known as any card at any number.
That's where a volunteer from the audience can name any card in the deck.
They can then give you a number from 1 to 52,
and the named card will be in that position when the cards are dealt off.
I've learnt how to do that trick using mathematics.
I've never performed it before.
I'm going to try it with a live stream on YouTube.
This is my live streaming setup that I normally use for online shows.
You can see I've got like, there's like a camera I've rigged up here,
and they're all, everything's on like movable arms.
I'm disproportionately proud.
There's like my little fold monitor, so I can see this, like my vision mixer.
I can like switch to my overhead camera, which you can see over here and back.
So that's all up there, and then this is like my YouTube dash.
You can see I've scheduled the live stream for like 14 minutes from now.
Okay, and then obviously laptop, keyboard, everything else.
So we'll see if this works.
It's, um, we'll find out.
Once I had a few people watching the live stream,
of course I hit them with a few warm-up tricks to get them in the mood.
And as you can see, it was just the one piece of rope the entire time.
Thank you very much, and oh, everyone, I appreciate your excitement.
The chat has exploded, so thank you very much for enjoying that.
Good, got that.
Happy with that take, Alex?
Got that.
Yep, Alex is happy with that.
Okay, calm down in the chat.
I appreciate what you're doing.
So I'm going to do a trick with this deck of cards, and I need a volunteer.
Someone in the chat needs to name a card, any card in the deck,
and they need to name a number from 1 to 52 for where they would like that card to end up.
And then I'm going to do an incredible any card at any number trick.
And so let's have a look.
Here we go.
So, uh, lots of people picking ridiculous.
Okay, someone wants the...
David wants the two of clubs.
Sorry, here we go.
Chris.
Chris Hoggetts wants the four of clubs at position 23.
So four of clubs at position 23.
So I'm going to see if I can get that to work.
And I'm going to be doing this with a brand new deck of cards.
Matt's internal thought process here.
I just thought I'd let you know that while I'm doing the trick,
we'll occasionally stop to look at what's going on inside my head.
I'm not going to actually explain why I'm doing any of these calculations for now.
That will come later.
But I am going to show you the mental steps that I'm going through.
And before I even start doing the trick,
I'm already picturing the order that the cards are in,
in a brand new deck of bicycle cards.
They go hearts, clubs, diamonds, spades.
The first two suits count up and the last two suits count down.
Okay, here we go.
Don't need those and don't need the jokers on the end.
First step, I'm working out what the beginning and ending indexes are,
as selected by the volunteer.
An important point though,
we don't number the cards from 1 through to 52.
All the mathematics requires them to be zero indexed.
So they go from index 0 to index 51.
The volunteer picked the 4 of clubs,
so that's 13 hearts plus 4 clubs.
It is the 17th card in the deck,
which means if we subtract 1, it's index 16.
They want that to go to the 23rd position,
which, if we subtract 1, is index 22.
Okay, so the way this trick is going to work is...
That look of concentration is me taking the starting index,
which in this case is 16,
and then multiplying it by 64.
My preferred method would be just to memorise the 64 times table
and then mentally look it up,
but your other option would be to double it six times.
That would work too.
Once you've got that multiple, the starting index,
you then subtract the target index,
in this case 22,
to give us the intermediate value of...
of...
1002.
The way this trick is going to work is
I'm going to do a series of in and out shuffles.
Behind this veil of seamless witty patter,
I'm now frantically trying to work out
what multiple of 52 is the next one up
from our intermediate value of 1002.
And it turns out 20 times 52 is 1040,
which overshoots 1002 by 38.
In a moment, I will have those two numbers, 20 and 38,
in my head.
See if you can spot the moment when I convert them into binary.
And so I'm going to work out what those are.
So they're going to be...
Behold, the grand finale,
where I bitwise add those two binary numbers in my head.
And that's like normal binary addition,
except you don't carry.
Each bit is done separately.
So 1 plus 0 is still 1.
0 plus 0 is 0.
However, 1 plus 1 equals 0,
and you don't carry any 1s.
Once I've done that,
the resulting 1s and 0s binary number
gives me the ins and out shuffles required
to complete the trick.
An in,
a in and an in,
and in,
that's going to be an out,
that's going to be an out.
Okay, we'll see.
I'm going to shuffle the cards.
I'm going to do an in shuffle, in shuffle,
out, out, in, out.
We'll see if that works.
Job done.
This is now Matt's internal thought process out.
All I have to do is execute those shuffles.
And when I'm saying in and outs,
I'm saying that in terms of
doing a perfect riffle shuffle.
So what I'm going to do the first time around,
I'll split the deck exactly in half,
and I'm going to push the top half
into the bottom half,
but because it's in,
it's going to come in one
before I start the riffle.
So that the top one is one in.
So that's my first in perfect shuffle.
There we go.
I'm then going to do it again,
another perfect in shuffle.
So that's the deck exactly in half there.
Let me go over offset by one for in.
I mean, obviously if you were actually a magician,
you'd be a lot quicker and smoother
at doing these shuffles than I am.
Don't worry.
We're not going to make you sit through
all of those shuffles.
We'll skip to the end.
However, if you want to double check,
I did do it properly.
The complete live stream is up,
unedited on my second channel.
Okay, here we go.
So now four clubs, 23rd position.
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22.
And the 23rd card is the four of clubs.
Oh, and the chat,
the chat is kicking off.
So in fact, it's gone so fast.
I'm not even keeping up
with the latest bit coming in.
Everyone's, people are just typing the word clap.
I appreciate what you're doing.
Here's how that works.
I was using a type of shuffle
called a faro shuffle.
And that's a perfect riffle shuffle
where you exactly divide the deck
into two piles of 26 cards.
And then an out faro shuffle
is where the top half of the deck
goes on the outside.
So the top and bottom cards don't change.
And an in faro shuffle is exactly the same,
but the top deck goes one in
and it means the top and bottom cards do change.
I'm actually just reusing old footage
from my previous video
I did about perfect bridge deals
because that's the video
which has spawned this one.
In that video,
I mentioned what I thought was an open question.
Get to that in a moment.
About if it's possible to use
in and out shuffles
to move any card
from any position in the deck
to any other position in the deck.
And if that does not sound familiar,
it's because I mentioned it
during the sponsorship message
at the end of the video
and nobody watches that.
Which is why I want to mention
right now that Jane Street
are sponsoring this video
as well as my channel in general.
They're great.
Apply for a job or internship
and tell them I sent you
or listen to their podcast.
Signals and threads
help support what I'm doing.
There you are.
There'll be more at the end of the video
if you watch that.
So in the previous sponsorship message,
which I'm not repeating,
they were only paying me once,
not doing that again,
I came up with this idea.
I said, look,
given it's possible to move
the top card to any position
using in and out Faro shuffles,
and we've known that,
well, for a very long time.
Someone called Elmsley described it in 1957
and Jason Davison
has a fantastic Numberphile video
going through the mathematics
of why that works.
I was like, well, hang on.
Surely you must be able to do any position
to any other position.
And I didn't realize
I actually had in the video
everything required
to prove that's possible.
You have to use this technique
and you use the fact
that the in and out shuffles
have inverses
because if it's possible
to use in and out shuffles
to take the top card anywhere,
in theory, you could reverse that
from any place
by doing the inverses,
which are just lots of regular shuffles.
And so hypothetically,
you pick your starting card,
you move it to the top position.
That's like the holding depot.
And then you do it again
to get it back down
to wherever you want.
So technically, yes,
you definitely can do that.
The question now is,
can you do it efficiently?
Section A.
It has been done before.
A lot of people emailed me
and said that Percy Diaconis
and Ron Graham,
I mean, talk about the two greats
of mathematics,
had written a paper
all about this exact problem
in the year 2007.
So I was a mere decade and a half
too late to ask the question.
Although actually,
the question was asked.
Elmsley, who first did the top card
to any position,
asked the same question in 1957.
They said they were able
to get any card
that's in a position
which is a power of two
back to the top,
but they weren't able
to get any arbitrary card
to any arbitrary position.
And it took 50 years,
okay, half a century,
that's a while,
I don't feel so bad now,
for someone to actually
answer the question
that not only is it possible,
but here's how it's done.
It was the working out
from Diaconis and Graham's paper
that I used to develop the technique,
which I used in the video.
So I thought I would step
very quickly through their logic
of how they came
to their incredible conclusions.
To follow along with their logic,
we're going to make two big assumptions.
So just go with me.
First of all,
we're going to pretend
we had no idea
about Elmsley's technique
to take the top card
to any position
with Farrow shuffles
and we're going to assume
a deck of cards
is only eight cards.
So I've got all hearts here.
I'm using the queen
instead of zero
and then I've got ace for one,
two for two,
all the way down to seven.
And that's because
all of these tricks,
you zero index the cards
and we're going to have a think.
All right,
how would we go about
working out
if it's possible
to use in and out shuffles
to take the top card
to any position of our choosing?
Except doing a Farrow shuffle
is a real pain.
I mean,
you've got to be able
to fit the card exactly in deck.
You've got to winter weave them.
If you're doing lots of working out
with like messing around with the cards,
it's super inconvenient.
So instead,
we're going to do
the much easier shuffle,
the inverse shuffle.
I'm going to start by
dealing the cards out into two piles.
Top card is always going to go on my left
and then the other card
and then repeat.
And so every second card
is going on this side
and all the in-between cards
are going on this side.
I'm undoing
the weaving process
of a riffle shuffle.
And now I'm going to put
the two halves back together.
And if I put the pile
that I started on
back on top,
it's like I've just undone
an out-shuffle,
reverse of an out-shuffle.
If I was to put this underneath,
it would be like
I've just undone an in-shuffle.
So I'm going to put it on top
and there you are.
I've just done one
inverse out-shuffle
very slowly
and you can see
it's moved a bunch of the cards around
and doing the reverse shuffle
by dealing it into two piles
way easier.
Also, because we're doing
inverse shuffles,
we're solving the inverse problem.
So bear with me.
We're actually going to work out
how to do backward shuffles
to take any card to the top.
And if we reverse it,
we can use forward shuffles
to take the top card to any position.
I'll show you how it works.
So I'm going to make one card
a bit easier to see
by swapping it out
for a different suit.
Where's, okay, six of spades.
You know what?
I'm going to swap that in
for the sixth card.
So now position six from the top,
you can see it's a different card.
We want to work out
what inverse shuffles
brings that card to the top position.
So we'll just give it a go.
I'll do my first inverse shuffle
by dealing them into two piles
and oh, there it goes.
It's in this pile,
which if I put that pile on top,
that makes it an inverse out-shuffle.
And each time I'm going to put
the sixth card when I see it
on the top pile,
so it gradually comes
all the way to the top.
So here we go.
We'll do the next one.
Oh, there it is.
Okay, it's in the in-shuffle pile.
So I'm going to put that on top.
I've just done an inverse in-shuffle
and oh, there it is.
So we only have to do it three times.
And once again, it's on this side.
So I'm going to do an inverse,
put that on top and there it is.
So an inverse out
followed by two inverse ins
takes the sixth position card
and puts it on top.
So if we do the reverse shuffles,
so just regular non-inverse shuffles
in the reverse order,
that will take the top card,
the zero position,
and move it to the sixth position.
And it's six in binary.
In, in, out.
One, one, zero.
That's six.
We have rediscovered
what Elmsley did
over half a century ago,
but we worked it out
systematically using this technique.
And very nicely,
if you're dealing out cards
into two piles,
three times,
you've got eight different options.
Because each time there's two options
for which one goes back on top.
And those eight different combinations
of ins and outs
correspond to all eight positions
in the deck of eight.
And so each one of them,
if you do the binary ins and outs
of the position you want it to end up in,
you'll be able to take the top card
to that position.
There you are!
We've managed to redo the old problem.
Now we head forward to the new problem.
To work it out,
we're going to switch from real cards
to these hypothetical cards here.
And we're going to try and find a formula
that takes their starting index.
And like before,
I've used queen for zero
and then ace all the way down,
so you can keep track
of where they started.
And this starting index i,
we want a formula that turns that
into the index after the shuffle.
So if you want, pick a card
and just track its index
as we put them into two piles.
And like before,
we're doing them one at a time.
This is the undoing of a riffle shuffle.
And now you can see we've got two decks
that both go from position zero
through to position three.
So we need a way to get from the starting i
to those numbers.
And we're basically,
we haven't changed the order of the cards.
We've just halved them.
There's half as many in each pile.
So actually the new index
is just half the starting index,
which works perfectly on the left.
Half of six, boom, three.
And it works for all the numbers on that side.
Over here, however, not so good.
Half of seven is three and a half,
not three, but we can fix that
by just rounding down.
This is the floor function.
You take half of the starting index
and then you round it down
to the nearest whole number.
And actually it doesn't hurt to do that
to the other one as well.
You still get the same answer out.
Now we can have the same formula.
It doesn't matter where the cards start
or which pile they go into.
They're going to have the index
which is half of their starting index
rounded down to the nearest whole number.
The problem though
is when we put the two piles back together
and I've done this
as if I'm doing an out shuffle,
half the cards are still correct.
These are all wrong.
They've now got half the deck on top of them.
We need to add four to all of these values
to get the correct new index locations.
We're going to take another leaf
out of Diaconus and Graham's deck
because they specified the deck
just in general to be two N cards.
They've assumed it's always
an even number of cards in the deck
and they always write it as twice N
where N is half the deck.
And that just makes life a bit easier
because for the cards on the right,
we can now just add N
to whatever we got from our previous formula.
Actually, if you have a look
at the cards that applies to,
it's all the odd starting positions
and we don't have to add N
for all the even starting positions.
And so we now know
if you do an inverse out shuffle,
this is how you can calculate
the new index for the cards
if they're starting in an even
or an odd position
and you can follow the same logic
for an inverse in.
And so what we actually know now
is the final position of a card
depends both on if you do an inverse out
or an inverse in shuffle
and it depends on
if it started in an even
or an odd index.
Just to simplify our life,
from here in,
we're going to assume all cards
are always in an even index.
Obviously, that's not going to be true.
Sometimes there will be an odd index,
but we're going to ignore that for now
and we'll compensate later on.
And the one thing to remember for later on
is the odd case,
the only difference is
where that plus N is.
In fact, you just swap inverse ins
and inverse outs for the odd case.
So we're just going to assume
everything is even
and then later on
we'll work out the ones
which were actually odd
and then just swap which shuffle we did.
Okay, onto the working out.
Let's say we have a card at index Q
and now we're going to do
an inverse shuffle
and we can either do
an inverse out shuffle,
which means we'll end up at Q on 2
and rounded down.
I'm going to avoid
writing the rounded down
every single time.
Or we could have done
an inverse in shuffle,
which would leave us at Q on 2 plus N.
Now, I'm actually going to simplify this
because we could take that N
and we could move it up
to be plus 2N there
on top of 2, like that.
And that's quite nice
because that 2N there,
that's just our original deck
of 52 cards,
but we're still working this out
in general.
Next step, another inverse out
gives us Q,
well, we half that again.
Now it's on 4.
Or we could have gone this way
and, oh, okay,
so we've got the same thing
happening again.
We got a Q on 4 plus N,
but if we want to move that up the top,
it would have been Q plus 4N on 4.
That was our inverse in.
Over here now,
we can do an inverse out
and that's,
well, I'm going to use
the simplified version
and then divide it by 2 again.
So that is now Q plus 2N on 4.
Or if we did our inverse in,
oh goodness,
this is becoming a bit of a mess,
bear with me here,
that would be the same as before.
It's Q plus 2N now on 4
because we half the original one
and then we've got to add on that N.
And, you know,
we probably want to put that N up the top,
which actually means
this would have been plus now 6N.
And interestingly,
we know in our specific case
our 2N is 52.
That's the starting deck.
And so if we write this
of how many extra 52s we're adding on,
here we're adding on zero lots 52.
Here, over here,
we're adding on,
that's plus two lots
of the original deck of 52.
Here we're adding on one lot
of the original deck of 52.
And here we're adding on three lots
of the original deck 52.
And if you read back up,
the inverse shuffles backwards.
That was an out and then an out.
So that's zero zero.
This one was an in and then an out.
So that's one zero over here.
We've got out then in zero one
and over here in then in one one.
And once again,
the binary,
if you read the inverse ins
and outs backwards,
gives us the multiple here
for how many lots of the deck size of 52
we are adding on.
So we can now write this in general.
If we set our number T
to equal the binary
for whatever combinations
of ins and outs we've got
when you read the inverse shuffles backwards,
we now know that for starting position Q,
we're going to add on
T lots of our original deck size,
2N, or in our case,
that's 52.
That's all then divided by,
well, lots of twos.
How many twos?
Well, officially we say there are R twos.
That's the number of deals we have to do.
So the bottom layer here in our tree,
if we keep splitting over and over,
has enough individual values.
So there's one for every single
possible position in the deck,
which is 52.
We have to go bigger than 52,
which in our case would be
2 to the 6 equals 64.
And we know that our 2N equals 52.
Put back in the requirement
that this all gets rounded down
to the nearest whole number,
and that gives us the final index P
after we've done those inverse shuffles.
All I had to do was take this formula
that Diaconis and Graham came up with,
which links the starting position
to the final position
in terms of the shuffles that you do,
and then actually find a way to do that
as a trick.
And the fact that we've done this
using inverse shuffles,
now we have to reverse it,
is why algebraically we have to take this,
and instead of having P equals at the front,
we've got to rearrange it to get T equals
so we can calculate what those shuffles are.
I initially ignored the rounding down.
All it means is everything on the left,
the T bit,
has to be bigger than the P bit.
So when you round it down,
you get P.
I then rearrange this,
put the Q on the other side.
The rounding down just means
that the 52T has to be greater than
or equal to everything on the right hand side.
And this is exactly what you saw me do in the trick.
I was working out the multiple of 52,
which was the next one up
from multiplying the starting position by 64
and subtracting the closing position.
And you want T to be as small as possible,
which is why I found the next multiple of 52 up.
Sometimes the one after that would also work,
because we've actually got 64 different parts
at the bottom of that tree diagram,
and some of them are duplicates.
So the next T up definitely works,
and the T above that sometimes works.
But the problem was,
we were assuming the card was always in an even index,
and we've done a lot of dividing by two
as we went down that tree,
and it only stays even if it was originally
like a power of two.
And so the working out for this
is slightly beyond the scope of this video.
You can check it out in the original paper,
but that correction term S
is actually just how far off that multiple of 52 is
compared to the 64 starting position
subtract final position.
And the reason we do a bitwise binary add
is we get a one whenever it was actually odd,
and by bitwise adding a one,
you flip a zero to a one and a one to a zero.
And so that means we do the opposite shuffle
in the cases where it's odd.
And that's it.
This is my version of how to perform
the theoretical trick devised by Diaconus and Graham.
Section B.
So of course, a lot of people emailed me
a link to the Diaconus and Graham paper,
which to be frank,
I probably should have done a Google for
before I put the question in my previous videos.
I thank everyone who sent that in,
but separately, a lot of people
just straight up solved the problem.
People started emailing me solutions
they'd worked out independently
to what had been done before them.
And the first one, I'm pretty sure,
was someone called Cameron Zach.
I reckon they emailed me about two and a half hours
after my video went live.
I can say with absolute confidence,
within five hours.
So what I love is the original question
put forward by Elmsley
took 50 years for someone to answer it.
I asked the same question
and it took someone two and a half hours.
So from 50 years to under five hours,
I don't know if that says more about
the state of modern mathematics
or just the state of, you know,
the number of people involved
in recreational mathematics.
I got more than one solution.
Cameron's was just the first one that came in.
Amazing.
And Cameron did it using a graph.
So they had a network of,
you take a card and its position
and then you link it to every other position
it could be in by an in or an out shuffle.
And then they used kind of an off-the-shelf,
shortest path finding algorithm.
I guess that's new.
That wasn't around 50 years ago.
And they just had to run through every combination.
Oh yeah, programming and computers, that's new too.
And so they were able to just double check
for every single starting and ending point
that there was a short path.
And they were all six or under,
which is exactly the same thing
that we found from the Diaconus and Graham technique.
So there you are.
I asked the question, possibly a bit naively.
Loads of people solved it.
Well done, everyone.
I am so proud of the people who watch these videos.
And for a fun bonus, even I wasn't expecting,
this is the inside of the deck
at the start of the trick.
And my animator, William Mahler said,
hey, I've got all these cards in my animation system.
I could very quickly put together
the way the six shuffles worked.
And I'd never seen inside the deck.
I had no idea what was happening.
And so you've already seen my internal monologue.
And Will very kindly rented out the internal shuffle log.
So I got to see what was happening
inside the deck of cards.
And it's kind of fun.
So I'm going to rewind this quickly.
From the beginning here,
you can track where that four goes.
And we know it starts at index 16.
And then the first shuffle,
well, this is now a normal riffle shuffle.
These aren't inverses.
These are the actual riffles I did.
I split the deck.
And if we skip forward a bit,
you can see they then mesh together.
And the index 16,
it's actually the 17th card in the deck.
And we say 16 because we're zero indexing.
Another way to think about it
is there are 16 cards above.
So if this four is index 16,
there are 16 cards above it.
Well, originally there were 16 cards above it
at the beginning here.
Once we've split it and then put it together,
every single one of those now has a buddy.
So three has a buddy,
two has a buddy,
eight has a buddy.
There's now twice as many of all of these,
plus a bonus one over here.
So the new index,
we can go from 16 to the next index
by multiplying it by two
and then adding one.
And so that gives us index 33.
And sure enough,
once you put this all together,
it is index 33.
Okay, then I did another in shuffle.
And oh, wait, hang on.
If I was to do the same process again
by doubling it and adding one,
that should be 67.
That's not right.
When, ah, that's actually index 14.
Okay, so it turns out there's a problem.
Our formula for doing a standard forwards in shuffle
is not simply two times the original index plus one.
It's two times the original index plus one
all mod 53.
And so if we mod 53,
67, that gives us 14.
Okay, up next, I split the deck again.
And now this is an out shuffle.
So the out shuffle, you can see here,
the four is going in
and every card that was above it
is getting a buddy with no extra ones.
So they've got a buddy, got a buddy.
They'd all double up right to the beginning.
One extra card.
That's a straight up and out shuffle.
All you have to do is take the original starting index
and double it.
So that 14 has now put us in position 28.
And that's all totally accurate.
Then I did another out shuffle.
Ah, the same problem again.
It's gone right to the beginning.
So I thought we should just double that again.
But that would give us 56.
But clearly we're not at 56, are we?
We're at five.
So it turns out the out shuffles is mod 51.
So really annoyingly, in and out have different moduli,
but it works.
Take 56, mod 51.
That's our correct position of five.
Up next, I did another in shuffle.
Double five, add one, gives us 11.
And then at the very end, I did an out shuffle.
And that's just a straight up double
to put us in position 22.
And I thought it was really nice
to actually watch this happen.
So two fun things.
First of all, we actually see some other patterns
in the cards.
So at the very beginning,
whatever that first shuffle is,
it takes the deck and puts it in colour order.
So now it's all reds, then all blacks.
And then the next shuffle always alternates the colours.
And then the next shuffle puts them in pairs of colours.
And you might also notice there's some symmetry
to where the cards are going.
So if I just back that one up.
Oh, actually, you can see Will loves hiding
all sorts of jokes in these videos.
And so you can see these are based on
my Festival of Spoken Nerd colleagues.
There's Steve Mould.
He's checked shirt.
There's Helen Arney with a ukulele.
And there's me with my no hair.
Now, you can see that there's the Steve's
are directly opposite the Steve's
and the Helen's opposite the Helen's.
And that actually carries on the whole way through.
Every shuffle, because the deck started symmetric,
the new arrangement is symmetric.
And at the very end, once it's all finished,
you look at the top cards.
Five, Ace, King, Nine, Two, Three.
And the bottom cards.
Five, Ace, King, Nine, Two, Three.
And so on.
Not only do we know that our card,
the Four of Clubs, is indexed 22 from the top,
its buddy card, the Four of Diamonds over here,
is indexed 22 from the bottom.
And actually, if you were to glimpse
some of the top cards here,
you would immediately know
what cards are at the bottom.
And that works for any number of riffle shuffles,
any combinations of ins and outs.
That's another little mechanism there
you can use for a whole different magic trick effect.
And the other crazy thing is now that we've got
the formulas for the in and out shuffles,
and we've got these different moduli, 53 and 51.
I'm just going to throw this out there.
If you raise 2 to different powers,
the smallest power of 2, which equals 1, mod 53, is 52.
And the smallest power of 2, which equals 1, mod 51, is 8.
And if you do in shuffles over and over and over again,
you get back to the original order after 52 shuffles.
And if you do out shuffles over again, it takes 8.
And that's not a coincidence.
It's always the order of 2 to the power of something,
modulus, either 1 more than how many cards are in the deck,
that's 2n plus 1, or 1 less, that's 2n minus 1.
That works for any decks whatsoever.
And 2 is what's known as a primitive root
for these different moduli.
And if you watch the bonus content for the video I did
about infinitely fragile primes,
it's exactly the same idea,
where we're looking for a power of something
which equals 1, modulus, a number.
Ah, maths!
Obviously, you're now going to use your free time
to learn how to do the mental arithmetic required
for this incredible, medium to incredible, card trick.
But, hypothetically,
that's not what you want to spend your free time on.
It brings me to our sponsor, James Street,
who I normally talk about applying for jobs
or internships there,
and, tell them I sent you,
this time I'm going to talk about their podcast,
Signals and Threads.
So this is probably a better use of your free time
than learning the card trick.
Ron Minsky talks to engineers about problems they're solving,
things like clock synchronization,
reliable multicast,
which I definitely know what that is.
And if you watched the live stream of me doing the trick,
that was an unreliable monocast,
in a very similar fashion.
So, if you want to hear about people at James Street
solving complex problems in the financial world,
anti-computing,
and all sorts of interesting, fun engineering things,
please do go check out the podcast.
Season 1 is out now,
and don't panic if you get hooked.
Season 2 will be out.
They're working on it as we speak,
probably late August.
So, as always,
check out the James Street website.
If you're looking for a job or a paid internship,
tell them I sent you.
Please do download and preferably have a listen to
the podcast Signalsandthreads.com.
Now, I feel like I've bigged up
the fact that people don't listen to the sponsorship message,
which means a very small percentage of viewers are still with me.
And I was thinking what would be a nice treat
to put at the very end of this video.
And I'm going to reveal,
I didn't have time to memorize
all the multiples of 52 and 64,
so I printed them out.
I printed out the times tables,
and I stuck it,
actually, can we,
Alex, can you,
over here, right,
so here's my live streaming set up again.
They were on,
can I, you can see,
okay, I had them like,
they were just like stuck to the side of my monitor there.
So if you watch,
watch the footage of me doing the trick again,
if I'm looking at that part of the screen,
I'm not just keeping my eye on the chat.
I'm also looking up my cheat sheet
for the multiples of 52 or 64,
because I only learned to do the trick yesterday.
All the binary and everything else,
I'm doing everything in my head,
other than that tiny lookup table,
which, I mean, I've memorized worse,
for less impressive tricks,
I just didn't have the time.
But I would memorize that table if I was going to do it again later,
but I didn't this time.
Don't tell anyone!
I don't want to see this in the comments.
I don't want to see people discussing this online.
This is just between me and the very few people
who watch all the way to the end of the sponsor message.
Thank you, Jane Street.
Fun side fact,
the theory that Faro shuffles are responsible for perfect bridge deals
was actually first floated by my friend Rob Easterway
in his book,
Maths on the Back of an Envelope.
And the first time he talked about it publicly
was actually at my book launch for Humble Pie.
And I totally hadn't clocked
that he's the person who came up with that theory.
So I thought I'd mention that.
You can actually get copies of Maths on the Back of an Envelope
from Mathsgear.
Now, this is actually my copy,
which Rob has signed for me.
And all copies on Mathsgear are signed.
The paperback is out now.
Do check it out.
Although, it won't also be graffitied on the back by Hannah Fry
to totally disown the quote she gave Rob.
