A062714 Minimal length of a sequence with terms from {1, 2, 3, ..., n} which contains, as a subsequence, each possible ordering of the n symbols 1, 2, 3, ..., n.
1, 3, 7, 12, 19, 28, 39, 52
Offset: 1
Examples
1, 2, 3, 1, 2, 3, 1 contains as a subsequence all of 123, ..., 321 and is minimal, so a(3) = 7. From _John W. Layman_, Aug 29 2008: (Start) The following is a sequence of length a(5)=19 with terms from 1,2,...,5 that contains as subsequences all of the 120 permutations of 1,2,...,5: {1,2,3,4,5,1,2,3,4,1,5,2,3,1,4,2,3,5,1} The proof is shown here: {1,2,3,4,5,-,-,-,-,-,-,-,-,-,-,-,-,-,-} {1,2,3,-,5,-,-,-,4,-,-,-,-,-,-,-,-,-,-} {1,2,-,4,-,-,-,3,-,-,5,-,-,-,-,-,-,-,-} {1,2,-,4,5,-,-,3,-,-,-,-,-,-,-,-,-,-,-} {1,2,-,-,5,-,-,3,4,-,-,-,-,-,-,-,-,-,-} {1,2,-,-,5,-,-,-,4,-,-,-,3,-,-,-,-,-,-} {1,-,3,-,-,-,2,-,4,-,5,-,-,-,-,-,-,-,-} {1,-,3,-,-,-,2,-,-,-,5,-,-,-,4,-,-,-,-} {1,-,3,4,-,-,2,-,-,-,5,-,-,-,-,-,-,-,-} {1,-,3,4,5,-,2,-,-,-,-,-,-,-,-,-,-,-,-} {1,-,3,-,5,-,2,-,4,-,-,-,-,-,-,-,-,-,-} {1,-,3,-,5,-,-,-,4,-,-,2,-,-,-,-,-,-,-} {1,-,-,4,-,-,2,3,-,-,5,-,-,-,-,-,-,-,-} {1,-,-,4,-,-,2,-,-,-,5,-,3,-,-,-,-,-,-} {1,-,-,4,-,-,-,3,-,-,-,2,-,-,-,-,-,5,-} {1,-,-,4,-,-,-,3,-,-,5,2,-,-,-,-,-,-,-} {1,-,-,4,5,-,2,3,-,-,-,-,-,-,-,-,-,-,-} {1,-,-,4,5,-,-,3,-,-,-,2,-,-,-,-,-,-,-} {1,-,-,-,5,-,2,3,4,-,-,-,-,-,-,-,-,-,-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-,-,-,-,-} {-,-,-,-,5,1,-,3,-,-,-,2,-,-,4,-,-,-,-} {-,-,-,-,5,1,-,3,4,-,-,2,-,-,-,-,-,-,-} {-,-,-,-,5,1,-,-,4,-,-,2,3,-,-,-,-,-,-} {-,-,-,-,5,1,-,-,4,-,-,-,3,-,-,2,-,-,-} {-,-,-,-,5,-,2,-,-,1,-,-,3,-,4,-,-,-,-} {-,-,-,-,5,-,2,-,-,1,-,-,-,-,4,-,3,-,-} {-,-,-,-,5,-,2,3,-,1,-,-,-,-,4,-,-,-,-} {-,-,-,-,5,-,2,3,4,1,-,-,-,-,-,-,-,-,-} {-,-,-,-,5,-,2,-,4,1,-,-,3,-,-,-,-,-,-} {-,-,-,-,5,-,2,-,4,-,-,-,3,1,-,-,-,-,-} {-,-,-,-,5,-,-,3,-,1,-,2,-,-,4,-,-,-,-} {-,-,-,-,5,-,-,3,-,1,-,-,-,-,4,2,-,-,-} {-,-,-,-,5,-,-,3,-,-,-,2,-,1,4,-,-,-,-} {-,-,-,-,5,-,-,3,-,-,-,2,-,-,4,-,-,-,1} {-,-,-,-,5,-,-,3,4,1,-,2,-,-,-,-,-,-,-} {-,-,-,-,5,-,-,3,4,-,-,2,-,1,-,-,-,-,-} {-,-,-,-,5,-,-,-,4,1,-,2,3,-,-,-,-,-,-} {-,-,-,-,5,-,-,-,4,1,-,-,3,-,-,2,-,-,-} {-,-,-,-,5,-,-,-,4,-,-,2,-,1,-,-,3,-,-} {-,-,-,-,5,-,-,-,4,-,-,2,3,1,-,-,-,-,-} {-,-,-,-,5,-,-,-,4,-,-,-,3,1,-,2,-,-,-} {-,-,-,-,5,-,-,-,4,-,-,-,3,-,-,2,-,-,1} (End)
Links
- Václav Chvátal, David A. Klarner, and Donald E. Knuth, Selected Combinatorial Research Problems, Stanford University Computer Science Department report STAN-CS-72-292, June 1972, page 26, problem 36 due to R. M. Karp.
- Michael Engen and Vincent Vatter, Containing all permutations, Amer. Math. Monthly, 128 (2021), 4-24, section 4; arXiv preprint, arXiv:1810.08252 [math.CO], 2018-2020.
- David Galvin, The n-Part Trilogy Problem
- D. J. Kleitman and D. J. Kwiatkowski, A Lower Bound On the Length of a Sequence Containing All Permutations as Subsequences, Journal of Combinatorial Theory, series A, volume 21, number 2, September 1976, pages 129-136.
- P. J. Koutas and T. C. Hu, Shortest String Containing All Permutations, Discrete Mathematics, Vol. 11, 1975, pp. 125-132.
- Maarten Löffler and Benjamin Raichel, Preprocessing Disks for Convex Hulls, Revisited, arXiv:2502.03633 [cs.CG], 2025. See p. 28.
- Malcolm Newey, Notes on a problem involving permutations as subsequences, Stanford Artificial Intelligence Laboratory, Memo AIM-190, STAN-CS-73-340, 1973.
- Sasa Radomirovic, A Construction of Short Sequences Containing All Permutations of a Set as Subsequences, Electronic Journal of Combinatorics 19(4), 2012, P31.
- Oliver Tan, Skip Letters for Short Supersequence of All Permutations, arXiv preprint arXiv:2201.06306 [math.CO], 2022.
- Przemysław Uznański, All Permutations Supersequence is coNP-complete, arXiv preprint arXiv:1506.05079 [cs.CC], 2015.
Crossrefs
Programs
-
Mathematica
NextTuple[x_, n_, l_] := Module[{i, x0 = x}, If[x0 == ConstantArray[n, l], Return[{}]]; For[i = l, i >= 1, i--, If[x0[[i]] < n, x0[[i]]++; Return[x0], x0[[i]] = 1]]]; Join[{1}, Table[p = Permutations[Range[n], {n}]; For[tl = n + 1, tl <= 50, tl++, tup = ConstantArray[1, tl]; While[tup = NextTuple[tup, n, tl]; tup != {}, If[Product[Count[tup, i], {i, 1, n}] == 0, Continue[]]; For[j = 1, j <= Length[p], j++, perm = p[[j]]; lst = tup; fnd = True; For[k = 1, k <= Length[perm], k++, If[lst == {}, fnd = False; Break[]]; p1 = Position[lst, perm[[k]], 1, 1]; If[Length[p1] == 0, fnd = False; Break[]]; p1 = First@First@p1; If[! IntegerQ[p1], fnd = False; Break[]]; lst = Drop[lst, p1]; ]; If[! fnd, Break[]]]; If[fnd, Break[]]]; If[fnd, Break[]]]; tl, {n, 2, 5}]](* Robert Price, Oct 13 2019 *)
Formula
Conjecture: a(n) = Sum_{k=1..n} A049039(k) = A337300(n). - Gerald Hillier, Jun 18 2016 [The conjecture is false for n=8, provided that a(8)=52 is correct. - Pontus von Brömssen, Aug 18 2025]
Extensions
a(5) = 19 from John W. Layman, Aug 29 2008
a(5)-a(7) are computed by Newey 1973, added by Max Alekseyev, Apr 16 2013
a(8) (using A136094) from Pontus von Brömssen, Aug 18 2025
Comments