login
Lexicographically first sequence of distinct terms such that any set of seven successive digits can be reordered as {d, d+1, d+2, d+3, d+4, d+5, d+6}, d being the smallest of the seven digits.
3

%I #16 Feb 03 2025 17:04:56

%S 0,1,2,3,4,5,6,7,8,9,34,56,78,23,45,67,12,345,60,123,456,71,234,560,

%T 1234,567,82,3456,712,34560,12345,601,2345,671,23456,782,34567,89,

%U 345678,93,4567,823,45671,234560,123456,789,3456782,345671,234567,893,45678,934,5678,9345,678,93456,7823,456712,345601

%N Lexicographically first sequence of distinct terms such that any set of seven successive digits can be reordered as {d, d+1, d+2, d+3, d+4, d+5, d+6}, d being the smallest of the seven digits.

%C As the digit 0 has no predecessor and the digit 9 has no successor here, sets of successive digits like {5,4,3,2,1,0,9} and {4,5,6,7,8,9,0} are forbidden.

%H Dominic McCarty, <a href="/A302502/b302502.txt">Table of n, a(n) for n = 1..10000</a>

%e Terms a(1) to a(10) are obvious;

%e a(11) is 34 because 34 is the smallest integer not yet in the sequence such that the elements of the sets {4,5,6,7,8,9,3} and {5,6,7,8,9,3,4} are seven consecutive digits;

%e a(12) is 56 because 56 is the smallest integer not yet in the sequence such that the elements of the sets {6,7,8,9,3,4,5} and {7,8,9,3,4,5,6} are seven consecutive digits;

%e a(13) is 78 because 78 is the smallest integer not yet in the sequence such that the elements of the sets {8,9,3,4,5,6,7} and {9,3,4,5,6,7,8} are seven consecutive digits;

%e etc.

%o (Python)

%o a, runLength = [i for i in range(10)], 7

%o def helper(s, k, l, a):

%o if k not in a: return k

%o return min([helper(s[(2-l):]+str(i), int(str(k)+str(i)), l, a) for i in range(10) if (k!=0 or i!=0) and s.find(str(i))==-1 and (all(d[n]+1==d[n+1] for n in range(l-1)) if (d:=sorted([int((s+str(i))[n]) for n in range(l)])) else False)])

%o while len(a)<100: a.append(helper(("".join(map(str, a)))[(1-runLength):], 0, runLength, a))

%o print(a) # _Dominic McCarty_, Feb 03 2025

%Y Cf. A228326 for the same idea with sets of two digits, A302173 (sets of three digits), A302499 (sets of four digits), A302500 (sets of five digits) and A302501 (sets of six digits).

%K nonn,base

%O 1,3

%A _Eric Angelini_ and _Jean-Marc Falcoz_, Apr 09 2018