OFFSET
1,2
COMMENTS
All terms starting with a(2)=10 must contain the digit 0.
From a(110)=809 onwards all terms must contain the digits 0 and 9.
Note that A011540 can also be defined as the sequence where a(n) is the smallest number not yet in the sequence that contains the smallest digit from a(n-1). See crossrefs.
EXAMPLE
a(2)=10 since 10 is the smallest positive number not yet in the sequence that contains the smallest and largest digit (i.e., 1) from a(1)=1.
a(6)=20 since 20 is the smallest positive number not yet in the sequence that contains the smallest and largest digits from a(5)=102.
MAPLE
N:= 1000: # for terms before the first term > N
A[1]:= 1:
S:= [$2..N]:
dmin:= 1: dmax:= 1:
found:= true:
for n from 2 while found do
found := false;
for i from 1 to nops(S) do
L:= convert(convert(S[i], base, 10), set);
if {dmin, dmax} subset L then
A[n]:= S[i];
dmax:= max(L);
dmin:= min(L);
found:= true;
S:= subsop(i=NULL, S);
break
fi
od;
od:
convert(A, list); # Robert Israel, Mar 28 2019
MATHEMATICA
Nest[Append[#, Block[{k = 2, d}, While[Nand[FreeQ[#[[All, 1]], k], SubsetQ[Set[d, IntegerDigits[k]], #[[-1, -1]] ]], k++]; {k, {Min@ d, Max@ d}}]] &, {{1, {1, 1}}}, 53][[All, 1]] (* Michael De Vlieger, Jan 27 2019 *)
PROG
(PARI) getFirstTerms(n)={my(Z=List(), A=List([1]), dd=[0, 1], c, m=1); for(k=2, +oo, forvec(y=vector(k, u, [u==1, 9]), listput(Z, y); for(i=1, #Z, if(m==n, return(Vec(A))); c=2; for(q=1, 2, for(j=1, #Z[i], if(Z[i][j]==dd[q], c--; break))); if(!c, dd[1]=vecmin(Z[i]); dd[2]=vecmax(Z[i]); listput(A, fromdigits(Z[i])); listpop(Z, i); m++; break)), 0))} \\ R. J. Cano, Feb 04 2019
(PARI) isok(k, vas, dm, dM) = {if (vecsearch(vas, k), return (0)); my(dk = Set(digits(k))); vecsearch(dk, dm) && vecsearch(dk, dM); }
nexta(va, vas, i) = {my(k=1, d=digits(va[i]), dm = vecmin(d), dM = vecmax(d)); while (!isok(k, vas, dm, dM), k++); k; }
lista(nn) = {my(va = vector(nn)); va[1] = 1; my(vas = vecsort(va, , 8)); for (n=2, nn, va[n] = nexta(va, vas, n-1); vas = vecsort(va, , 8); ); va; } \\ Michel Marcus, Feb 05 2019
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Enrique Navarrete, Jan 24 2019
STATUS
approved