A000376 Topswops (2): start by shuffling n cards labeled 1..n. If the top card is m, reverse the order of the top m cards. Repeat until 1 gets to the top, then stop. Suppose the whole deck is now sorted (if not, discard this case). a(n) is the maximal number of steps before 1 got to the top.
0, 1, 2, 4, 7, 10, 16, 22, 30, 38, 51, 63, 80, 101, 112, 130, 159, 191, 207, 231
Offset: 1
References
- D. E. Knuth, TAOCP, Section 7.2.1.2, Problems 107-109.
Links
- Linda Morales and Hal Sudborough, A quadratic lower bound for Topswops, Theoretical Computer Science, Volume 411, Issues 44-46, 25 October 2010, Pages 3965-3970.
Programs
-
Python
def a(n): # see A000375 for ts return max(ts(d, var=2) for d in P(range(1, n+1))) print([a(n) for n in range(1, 11)]) # Michael S. Branicky, Dec 11 2020
Extensions
a(14)-a(15) from James Kilfiger (mapdn(AT)csv.warwick.ac.uk), Jul 1997
a(16)-a(17) from William Rex Marshall, Mar 28 2001
Definition clarified by Franklin T. Adams-Watters, Jan 24 2007
a(18) from Quan T. Nguyen, William Fahle (tuongquan.nguyen(AT)utdallas.edu), Oct 21 2010
a(1)=0 prepended by Max Alekseyev, Nov 18 2010
a(19) from Moritz Franckenstein, Dec 14 2010
a(20) from Moritz Franckenstein, Apr 16 2011
Comments