encyclopegia.org

Topswops

Topswops (and the variants Topdrops, Bottomswops and Bottomdrops) are mathematical problems devised and analysed by the British mathematician John Conway in 1973.[src] Contrary to other games and problems introduced by Conway, these problems have not received much attention from the scientific community.[src] Two famous mathematicians who have contributed to the problem are Martin Gardner and Donald Knuth.[src]

Topswops (and the variants Topdrops, Bottomswops and Bottomdrops) are mathematical problems devised and analysed by the British mathematician John Conway in 1973.[src] Contrary to other games and problems introduced by Conway, these problems have not received much attention from the scientific community.[src] Two famous mathematicians who have contributed to the problem are Martin Gardner and Donald Knuth.[src] ==Formulation== In each variant of the problem, Conway uses a deck of playing cards.[src] Since the numerical values of the deck are only relevant, only one suit is used.[src] This is mathematically equivalent to a row of integers from 1 to N .[src] A shuffled pile of cards is written as A[1], ..., A[N] .[src] ===Topswops=== For topswops the following algorithm is applied: Consider the first card from the pile (which is A[1] ) Take the first A[1] cards from the pile Swap these cards and place them back on the pile Repeat step 1, 2 and 3 until the top card is 1 The final configuration of the row always starts with 1 .[src] The topswops problem is occasionally named differently, with naming including deterministic pancake problem, topswops, topswaps, reverse card shuffle and fannkuch.[src] The problem formulated by Conway is the following: Which initial configuration leads to the maximum number of 'swops' before the algorithm terminates?[src] In literature there are some attempts to find lower and upper bounds for the number of iterations f(N) .[src] Theorem: f(N) is bounded by 2^{N-1} .[src] Proof by Herbert S.[src] Wilf: Consider a permutation A[1] to A[N] of the row 1 to N .[src] As an example, we consider 7,2,11,8,5,13,6,1,9,10,3,12,4 .[src] We are specifically interested in numbers which are at 'the correct position'.[src] These are: 2, 5, 9, 10, 12.[src] We define the Wilf number as 2^{(2-1)}+2^{(5-1)}+2^{(9-1)}+2^{(10-1)}+2^{(12-1)} = 2833 .[src] Claim: after each iteration of the algorithm, the Wilf number increases.[src] Proof: We perform one iteration of the algorithm.[src] Every number at 'the correct position' and larger than A[1] , leaves the Wilf number unchanged.[src] The remaining numbers at 'the correct position' will in general not be at 'the correct position' anymore.[src] Nevertheless, the A[1] 's number is at the correct position.[src] And since the sum of the first A[1]-1 Wilf numbers is always smaller than the Wilf number of A[1] , the total Wilf number always increases (with at least 1 per iteration of the algorithm).[src] \square The maximal Wilf number is found when each number is at the correct position.[src] So the maximal Wilf number is 2^{N+1}-1 .[src] By refining the proof, the given upper bound can be proven to be a real upper bound for the number of iterations.[src] \square .[src] The upper bound is loose, whereas the lower bound is quite tight.[src] .[src] The data points in the graph are only some permutated rows, and are lower bounds of the real value.[src] The upper bound is again very loose, whereas the lower bound is relatively tight.[src] Theorem: f(N) is bounded by the (N+1) th Fibonacci number.[src] Proof by Murray S.[src] Klamkin: Suppose that during the algorithm, the first number A[1] takes on in total k distinct values.[src] Claim: f(N) \leq F_{k+1} .[src] Proof: We prove the claim by mathematical induction.[src] For k=1 , the algorithm directly terminates, hence, f(N)=0 .[src] Thus A[1]=1 and since F_2 = 1 the claim is proven.[src] We now take some k \geq 2 .[src] All k values that A[1] takes on, are ordered and can be written as: d_1 .[src] Suppose that the largest value of these values, which is d_k , occurs for the first time at position 1 during iteration r of the algorithm.[src] Denote t=A[d_k] .[src] During the (r+1) 'th iteration, we know A[1]=t and A[d_k]=d_k .[src] The remaining iterations will always retain A[d_k]=d_k .[src] Hence A[1] can now take on at most k-1 values.[src] Using induction for k , it follows that f(N) - r \leq F_k and also that d_1=1 .[src] \square Suppose we would exchange d_1=1 and d_k in iteration r Then A[1]=1 and the algorithm terminates; f(N)=r .[src] During the algorithm, we are sure that both d_k and t have never been at position A[1] , unless t=1 .[src] Suppose t=1 .[src] Then r \leq F_k since A[1] takes on at most k-1 distinct values.[src] So it follows that f(N) \leq r+1 \leq F_{k+1} .[src] Suppose t>1 .[src] Then r \leq F_{k-1} since A[1] takes on at most k-2 distinct values.[src] Using the claim, it follows that f(N) \leq F_k + r \leq F_{k+1} .[src] This proves the theorem.[src] \square Besides these results, Morales and Sudborough have proven that the lower bound for f(N) is a quadratic function in N .[src] The optimal values are, however, still unknown.[src] There have been several attempts to find the optimal values, for example by A.[src] Pepperdine.[src] For rows with 19 or fewer numbers, the exact solution is known.[src] Larger rows only have lower bounds, which is shown on the right.[src] It is yet unknown whether this problem is NP-hard.[src] ===Topdrops=== A similar problem is topdrops, where the same playing cards are used.[src] In this problem, the first card of the pile is shown (and has value A[1] ).[src] Take the first A[1] cards of the pile, change the order and place them back on the bottom of the pile (which contrasts topswops, where the cards are placed at the top).[src] This problem allows for infinite loops.[src] As an example, we consider the row 2,1,3,4.[src] By applying the algorithm, the following sequence is obtained: 2 1 3 4 3 4 1 2 2 1 4 3 4 3 1 2 2 1 3 4 whereafter the original row is found again.[src] ===Botswops=== In this variant, the bottom card of the pile is taken (and again named A[1] ).[src] Then the first A[1] cards of the pile are swapped.[src] Unless the bottom card is the highest card in the pile, nothing happens.[src] This makes the problem uninteresting due to the limited behaviour.[src] ===Botdrops=== The final variant is botdrops where the bottom card of the pile is taken (again A[1] ).[src] In this variant, the bottom A[1] cards are swapped.[src] ==External links== OEIS: page 375 (topswops) OEIS: page 376 (topswops which ends up sorted) Rosetta code: Computing Topswops in multiple programming languages Topswops competition to compute the maximal number of iterations[src]

79 sentences · 79 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Topswops." encyclopegia.org, 2026, https://encyclopegia.org/wiki/topswops. Accessed 27 November 2026.

Chicago

"Topswops." encyclopegia.org. Accessed November 27, 2026. https://encyclopegia.org/wiki/topswops.

APA

encyclopegia.org. (2026). Topswops. Retrieved November 27, 2026, from https://encyclopegia.org/wiki/topswops

Accessed November 27, 2026 · CC BY-SA 4.0 · citation page · JSON

CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1347913326 · 0.5 · snapshot enwiki-001347913326

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.