Alternating card permutations.

81 views
Skip to first unread message

Atanasios Boulougouris

unread,
Jul 26, 2026, 11:33:55 AM (10 days ago) Jul 26
to SeqFan

Hello everyone,


First, to be clear: I am absolutely not a mathematician (nor a native English speaker, for that matter)—just someone who is… curious.


I’m not sure what to make of this, where or to whom to share it, or if it has any mathematical significance. Maybe there’s a formula for it—I really don’t know. I found the OEIS website and this forum, and thought this might be the right place to discuss it… Or maybe not.

If not, please excuse me for the inconvenience. (But isn't there such a thing as a stupid question?)


Some time ago (years, perhaps?), I had a standard 52-card deck (Ace, 2, 3, …, Jack, Queen, King) and wanted to test a shuffling method. Here’s how I did it:


With the cards in their original order (Ace, 2, 3, …, Jack, Queen, King), I took the first card (Ace), placed the second card in front of the Ace, the third card behind the Ace, the fourth card in front of the 2, the fifth card behind the 3, and so on—alternating between front and back.


At the end of the “sequence,” I started over: first card, second in front, third behind, fourth in front, fifth behind, etc.


After a certain number of such “sequences,” the cards returned to their original order (Ace, 2, 3, …, Jack, Queen, King), regardless of the number of cards. That was my first surprise. I manually tested several deck sizes (10, 13, 20, 26, etc.). Every time, the cards returned to their original order.


I noticed that the number of “sequences” required varied with the number of cards, but **not** proportionally.


Doing this manually was tedious, so I created a spreadsheet to automatically calculate the number of sequences needed (to return to the original order) for a given number of cards, out of pure curiosity (from 1 to 300, or more). Here are two or three observations:


1. For consecutive even and odd numbers of cards, the number of “sequences” required is the same. Okay.

2. The number of sequences does **not** increase proportionally with the number of cards (for example: 100 cards require 33 sequences, but 102 cards only require 10 to return to the original order).

3. The number of sequences is not random; they “probably” follow a certain “logic.” However, they can be very uneven—jumping from 9 sequences for 28 cards, to 30 for 30 cards, and then dropping to 6 for 32 cards.


Anyway, you’ll probably be better equipped than I am to judge if this is worth exploring… or not.


Thank you!

(I can share the spreadsheet if needed.)

Allan Wechsler

unread,
Jul 26, 2026, 12:01:53 PM (10 days ago) Jul 26
to seq...@googlegroups.com
Did you in fact look up the resulting sequence in the OEIS? The permutation you describe is straightforward enough that I would imagine somebody has investigated its order before. I'm going to go see if I can find it now.

-- Allan

--
You received this message because you are subscribed to the Google Groups "SeqFan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seqfan+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/seqfan/4fa01aca-5f49-452b-bf5a-82cb5dc14617n%40googlegroups.com.

Atanasios Boulougouris

unread,
Jul 26, 2026, 12:18:49 PM (10 days ago) Jul 26
to SeqFan
Indeed, I haven't looked. Not being an expert on the subject at all, I wouldn't know what to look for. I would, however, be curious if you happen to find anything on it. Thank you.

brad klee

unread,
Jul 26, 2026, 12:26:19 PM (10 days ago) Jul 26
to seq...@googlegroups.com
> Indeed, I haven't looked. Not being an expert on the subject at all, 
> I wouldn't know what to look for. 

OEIS isn't only designed by experts. The interface is very simple and 
allows you to search from explicit calculations such as you claim to have
in your spreadsheet. 

Now that all these LLM's can program and search online, they can also
be useful in finding the facts. Harm.On.ica S-O-L suggested here:


There's also a page of analysis ( from Chat GPT @ Open AI plus the 
memory I've been renting for $20/mo while they watch my every move ).

There's tiny fine print disclaimer on Chat GPT website, but it's really no
enough. I can't vouch that A019567 is really what you're after. 

A more reliable search would convert some fairly literal, strict pseudocode
into computer code, get the terms, then feedback to the OEIS search. 

If this response isn't helpful, please let me know. 


All the best, 






--Brad

 













Allan Wechsler

unread,
Jul 26, 2026, 12:30:45 PM (10 days ago) Jul 26
to seq...@googlegroups.com
Yes. Your procedure has already been described, and the number of required repetitions listed, at oeis.org/A145787 . Since the last card of an odd deck always stays put, it's more natural to do this with an even deck of size 2n; the number of shuffles for such even decks is described at oeis.org/A019567 . Here we learn that these shuffles are called "Monge shuffles" or "Mongean shuffles". According to Wikipedia, Gaspard Monge wrote about them in 1773.

This is what OEIS is for. If you discover an interesting sequence of integers, just type them into the search box at OEIS -- to find your sequences, I only had to enter the first 10 entries, which were easy to compute. After typing 10 terms, there was only one sequence that matched, and it was the one you were describing.

To learn how to use OEIS, I suggest doing exactly that: type the first ten terms of your sequence into the search box, and then when it takes you to A145787, read the whole entry. Then follow the link to A019567, and read more. Perhaps you would like to learn more about Monge, who apparently thought like you, or to read some of the links. There is an enormous amount to learn here, and many unsolved problems.

-- Allan

Atanasios Boulougouris

unread,
Jul 26, 2026, 12:49:36 PM (10 days ago) Jul 26
to SeqFan
Wonderful. I knew I'd find the answer one day. Thank you for your patience and very precise explanation. And please forgive my ignorance. I'm finally going to (try to) learn more about this subject.

Boulou
PS: 1773??? I'm really several centuries behind... ;))

Ruud H.G. van Tol

unread,
Jul 26, 2026, 12:54:36 PM (10 days ago) Jul 26
to seq...@googlegroups.com

On 2026-07-26 18:49, Atanasios Boulougouris wrote:
> PS: 1773??? I'm really several centuries behind... ;))

No worries: the times I found out that the Chinese already covered my
idea 3 millennia ago, is a sequence too.

-- Greetings, Ruud

Atanasios Boulougouris

unread,
Jul 27, 2026, 6:08:09 PM (9 days ago) Jul 27
to SeqFan

I’m reaching out to you with a question about the sequence **A145787**.

From what I understand, this sequence indicates the number of steps required to return to the initial order.

My question is: **Can the intermediate card arrangements within these steps also be considered as sequences?**


For example, with **2000 cards** (which requires 500 intermediate steps to return to the original order):

- At the **41st step**, I obtain the following sequence:

  **4, 11, 18, 25, 32, 39, 46, 53, 60, 67, 74, 81, 88, 95, 102…**

  Here, I notice a clear pattern.


However, at the **49th step**, I get:

**696, 1915, 524, 868, 1743, 352, 1040, 1571, 180, 1212, 1399, 8, 1384…**

And at the **359th step**:

**814, 1561, 67, 1694, 681, 947, 1428, 200, 1827, 548…**

In these cases, I don’t see any obvious correspondence or pattern.


Thank you for your insights!

Atanasios Boulougouris

unread,
Jul 28, 2026, 3:10:03 AM (9 days ago) Jul 28
to SeqFan

To complete my point, the intermediate suites have a structure. These are not random sequels.


In the example of a series of 70 cards, at the 23rd displacement:

48,2,45,51,5,42,54,8,39,57,11,36,60

48.        51.        54.         57.         60

     2.          5           8.          11

        45.         42.       39.         36

brad klee

unread,
Jul 28, 2026, 7:47:20 AM (8 days ago) Jul 28
to seq...@googlegroups.com
OEIS focuses on infinite sequences. There are ways to get 
around that, i.e. making triangles, appending 0's. 

In this case, you would need to justify your interest probably 
working from cyclic subgroups or similar. Why does this matter? 

Whoever's shuffle is just one type of shuffle. There are other 
shuffles out there. Do we have recurrence data for those? 

If you don't know any other shuffles, go to a game store and 
ask people what they do to randomize their card decks. Or 
study machines that Casinos use. 

"Pile shuffle" is a popular one I've seen for large decks. This is
basically a permutation into n-bins story. Like your previous 
case, it is guaranteed to return to identity:

Harm.On.ica S-O-L knows about pile shuffles too: 

Exploring pile shuffle would potentially be useful and something 
that a few other people would care about and learn from. 

Personally, I find dice to be more interesting because they 
have non-commuting geometry built in. 

Sure you can rotate a card 180 degrees two different ways
(I've heard the phrase "north-southing" for illegal shuffles) 
to isometry but that usually commutes with shuffle, right? 

Shuffling dice might be a good idea, and you would have more 
choice for algorithms. No mater what else, if you have a finite 
state space and an iterator, you will always get recurrence. 

All this said, permutation theory is relatively irrelevant to actual 
game play where you have to do some statistics. 

An interesting theorem I found the other day with claude (which 
started this whole insane AI interest) was contestedly even heatedly
debated, but ultimately agreed on by others: 

If you roll three D6 against one D20, the high roll (or low roll) is 
a fair game with 50:50 odds. The reason is that the distributions
have the same centers and are reflect symmetric around those
centers. Those two conditions turn out to be good enough for 
competing any two RNG fairly, even when one RNG has a 
smaller domain than the other. 

The domains [3,18] and [1,20] do not line up exactly, but they 
have the same mean 10.5, a fact which really upset a colleague
of mine leading to a day's long discord argument.  

If you want to contribute something to OEIS, that's what I'd suggest 
as a first step: Don't try and make an RNG that equals the same 
A number every time. Do a probabilistic search of surrounding 
A numbers (not literally, by cross-ref), maybe make some bigger
jumps toward the core keyword, then stop and reflect. 

Once you can see the forest, you'll notice where the trees are 
missing. Then you can potentially submit a new fun and games
sequence.  


Best wishes,
 









--Brad









Atanasios Boulougouris :

brad klee

unread,
Jul 28, 2026, 8:32:23 AM (8 days ago) Jul 28
to seq...@googlegroups.com
PS. See also: 


When previously I used the term "iterator" implicitly I meant 
"permutation iterator". Another example is above. 

There are possibly deterministic iterators that enter a limit 
cycle. Those will still have a recurrence time, just not to the 
initial condition. 

Stochastic iterators--as might be drawn from an entropy pool 
--they could repeat sometime, but certainly aren't guaranteed
to repeat regularly. 

Basically, unless you're using thermodynamics somehow, 
or coin flips or dice rolls (caloric energy?) you'll eventually 
get periodic recurrence. 



--Brad

Atanasios Boulougouris

unread,
Jul 28, 2026, 3:21:52 PM (8 days ago) Jul 28
to SeqFan
"OEIS focuses on infinite sequences." Okay, I understand better now. My question didn't really make sense.
First of all, thank you for taking the time to reply. I was simply looking for a rational explanation for my question. And I have my answers.

As a distant ancestor once said:
The ignorant person asserts,
the learned person doubts,
the wise person reflects.

I hope I'm not the first, the second is beyond my expertise, and I'm trying to learn from the third.
It was a pleasure to have the opportunity to speak with you.

Best regards.
Boulou



PS: One last question. What if the number of cards = ∞? 🤔
No, I'm just kidding, don't answer… 🙄

brad klee

unread,
Jul 28, 2026, 3:56:52 PM (8 days ago) Jul 28
to seq...@googlegroups.com
> PS: One last question. What if the number of cards = ∞? 🤔

Recently I was thinking about the "Hilbert Hotel" and it seemed that 
the "Theodorus Integers" being a subset of algebraic numbers caused
a problem for Cantor's diagonal argument.

What if there was some sort of Maxwell's demon type of thing that kept 
engineering the "one is always missing" construction so that always
another algebraic integer was being added to the set? 

The algebraic integers are countably infinite, so we're missing the point
if that's all we think there is to Cantor's argument. 

After re-reading Cantor's original paper, I realized that it really depends 
more on power-set growth of sort functions than it depends on the "one 
is always missing" construction. 

This reasoning almost brings into focus the relation of uncountable infinity 
to the set of transcendental numbers, because transcendental numbers are 
more of a continua than we are really used to dealing with. 

If you want to understand all possible sorts of an infinite number of cards,
then you definitely need to study transcendental number theory. 

I meant to also mention that sort functions are a fundamental area of 
computer science where you can learn about complexity statistics. 

The basic question is like this: If a deck of whatever, maybe dice, maybe
cards, maybe just elements of an ordered list--if some deck of some thing 
starts out in a random state, what is the time expectation for a generic 
comparison iterator to obtain one unique correct sort order? 

By comparison iterator I mean that you might choose two items, compare
them based on some function of color or magnitude, decide that one goes 
in front of the other, transpose them if necessary, then move to the next 
two items. 

For example, here's bubble sort: 


And here's quicksort: 


Quicksort has a better average performance than bubble sort. 



All the best , 







--Brad





 













Atanasios Boulougouris

unread,
Jul 29, 2026, 2:29:30 AM (8 days ago) Jul 29
to SeqFan

All the mathematical concepts you present—and which I admit I still need to assimilate—lead me to the following reflection:


If the number of cards is infinite, then the number of moves required to return to the initial sequence is **0 (zero)**, not infinity, because the first "shuffle" never completes.


By analogy, it would be like asking: *How many times must one roll a die with an infinite number of faces (and thus a sphere) to land on the same "number" as the starting face?* It would never stop rolling. (Assuming an inertial environment, of course.)


What are your thoughts on this?

brad klee

unread,
Jul 29, 2026, 2:43:44 AM (8 days ago) Jul 29
to seq...@googlegroups.com
> If the number of cards is infinite, then the number of moves required to 
> return to the initial sequence is **0 (zero)**, not infinity, because the 
> first "shuffle" never completes.

Disagree. The shuffle transposing even and odd subsets by nearest 
neihgbors starting at (0,1)(2,3)... -> (1,0)(3,2)... -> (0,1)(2,3)... this has 
period 2 and it can be imaginary applied in parallel. 

In the story of Hilbert's Hotel (https://arxiv.org/abs/1403.0059) I think it's 
assumed that all carriages arrive at the same time. 

> *How many times must one roll a die with an infinite number of faces 
> (and thus a sphere) to land on the same "number" as the starting face?*

The point of the Cantor construction is that the answer isn't the same 
as a dice with countably infinite sides. It's even more never, because 
the platonic perfect sphere has uncountably many normal vectors. 

What is your sphere made out of? If it's matter, somewhere at the 
quantum level it begins to look more like a dice, but that might not 
resolve the countability problem because the Schroedinger wave 
function is continuous-valued and difficult to solve for a dice-sized
clump of matter. 

If you want something countable, the prompt I came up with was 
decent okay. I think it had something to do with the Shuffle you
started on. Here it is again: 

> One deck, N cards. Draw M. compute step size d=Floor((N-M)/M), 
> start counting from bottom and index each card before insertion. 
> place top card at location 0, the bottom of the deck. Place second 
> card at location d, third at 2d, etc. M*Floor((N-M)/M) <= N-M , 
> therefore we know the last card lands at a valid location. We're 
> back to the condition of N cards in a stack, so we pop M of them 
> again and repeat the process. How many iterations until 
> recurrence? Try again.  

Let me know if you can calculate these numbers it might be worth
an inclusion to the OEIS. I'll look at it in more detail. 



All the best, 











--Brad


























On Wednesday, July 29th, 2026 at 1:29 AM, Atanasios Boulougouris <boul...@gmail.com> wrote:

Atanasios Boulougouris

unread,
Jul 29, 2026, 6:56:36 AM (8 days ago) Jul 29
to SeqFan

Before I begin, I should mention that I translated the following into English myself. I hope I have not introduced any errors or awkward wording.



"Please let me know if you are able to compute these numbers; they may be worthy of inclusion in the OEIS. I shall examine the matter more closely myself."


Unfortunately, I am quite incapable of doing so.


Moreover, I am only beginning to understand (with considerable difficulty) the reasoning underlying your argument. It took me the better part of yesterday evening to assimilate these concepts. Wikipedia proved to be an invaluable aid.


To begin with, my analogy with a die was intended purely as a hypothetical illustration. It was simply my way of expressing, in my own words, the idea I was trying to convey.


It may well be possible to prove that a die with infinitely many faces has, in fact, no faces at all. However, could one not regard an atom(*) metaphorically as a face, in much the same way that a point may be regarded as belonging to a line?


One can also prove that

1 + 2 + 3 + 4 + 5 +... = -1/12,

although I must confess that I remain unconvinced by this result. In any event, I do not possess the mathematical background required to defend my intuition rigorously.


All I have is my own reasoning, which suggests that if n = ∞, then the first shuffle can never be completed, making it impossible to begin the second. Consequently, returning to the initial configuration would itself become impossible (that is, it would occur with probability zero).


The notion of infinity is genuinely counterintuitive.


I shall endeavour to study the concepts you have mentioned more carefully, in the hope of gaining a better understanding of your point of view.


(*) Incidentally, if it were possible to conceive of a die with infinitely many faces, would it not follow, at least in principle, that its surface area would have to be greater than—or at least equal to(**)—that of the universe?


(**) Assuming, of course, that the universe itself is not finite.



Boulou

brad klee

unread,
Jul 29, 2026, 10:24:05 AM (7 days ago) Jul 29
to seq...@googlegroups.com
Unfortunately, I am quite incapable of doing so.

Sounds like bad attitude to me, but if not, you might be in the wrong place. 

The question to ask here is very constrained: What other integer sequences 
can we calculate? 

All I have is my own reasoning,

Study engine design? 

Incidentally, if it were possible to conceive of a die with infinitely 
> many faces, would it not follow, at least in principle, that its surface 
> area would have to be greater than—or at least equal to(**)—that of the universe?
> Assuming, of course, that the universe itself is not finite.

Until better tests are developed, the effective surface area of the universe is 
what's called the "Cosmic Microwave Background". It is measured at a finite 
but increasingly precise resolution using antenna and possibly bolometers.  

Inside the so-called observable universe we assume or reason to finitely 
many atoms. A common estimate is 10^80. If the patent for your new tool 
calls for 10^80 faces, you will need to file it in another universe! 


Unfortunately, this is the last free answer I can give you unless you contribute 
some calculation, whether it is the one I suggested, or another that's more
immediately within your means. 


Thanks for your time, 








--Brad





















Reply all
Reply to author
Forward
0 new messages