

A351059


a(n) is the smallest number not yet in the sequence that has three digits in common with a(n1), starting with a(1) = 1.


2



1, 111, 10, 100, 102, 101, 103, 110, 104, 114, 14, 141, 41, 144, 124, 112, 12, 121, 21, 122, 120, 200, 20, 202, 201, 210, 211, 123, 113, 13, 131, 31, 133, 130, 300, 30, 303, 203, 220, 204, 222, 2, 1222, 23, 223, 32, 232, 132, 212, 125, 115, 15, 151, 51, 155, 105
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,2


COMMENTS

See A350671 for the definition of "x has N digits in common with y".


LINKS



EXAMPLE

a(2) = 111 because it is the smallest number that has exactly three digits in common with a(1) = 1; similarly, a(3) = 10 because it is the smallest number that is not already in the sequence that has exactly three digits in common with a(2) = 111 and a(4) = 100 because it has three digits in common with a(3)= 10.


PROG

(Python)
from itertools import islice
def c(s, t): return sum(t.count(si) for si in s)
def agen(): # generator of terms
an, target, seen, mink = 1, "1", {1}, 2
while True:
yield an
k = mink
while k in seen or c(str(k), target) != 3: k += 1
an, target = k, str(k)
seen.add(an)
while mink in seen: mink += 1
(PARI) isok(k, d, va) = {if (#select(x>(x==k), va), return(0)); my(dk=digits(k)); sum(i=1, #dk, #select(x>(x==dk[i]), d)) == 3; }
lista(nn) = {my(va = vector(nn)); va[1] = 1; for (n=2, nn, my(k=1, d = digits(va[n1])); while(!isok(k, d, va), k++); va[n] = k; ); va; } \\ Michel Marcus, Jan 31 2022


CROSSREFS



KEYWORD

nonn,base


AUTHOR



STATUS

approved



