OFFSET
1,2
COMMENTS
Comment from Michael S. Branicky and N. J. A. Sloane, Jan 31 2022: (Start)
The crux is the definition of "x has two digits in common with y". Take each digit d of x in turn, reading from left to right, and see how many times d appears in y. The sum of all these counts must be 2. E.g., x = 122 has two digits in common with 2 because the first 1 has zero matches, the first 2 has one match, and the second 2 has one match. Again, x = 110 has three digits in common with 103 because the first 1 has one match, the second 1 has one match, and the zero has one match.
In general, if x has decimal expansion x_1...x_e, and y has decimal expansion y_1...y_f, and delta(u,v) = 1 if u=v, 0 otherwise, then the number of digits in common between x and y is Sum_{i=1..e} Sum_{j=1..f} delta(x_i, y_j). (End)
Terms computed by Claudio Meller.
EXAMPLE
a(2) = 11 because it is the smallest number that has exactly two digits in common with a(1) = 1; similarly, a(3) = 10 because it has two digits in common with a(2) = 11 and a(4) = 102 because it is the smallest number that is not already in the sequence that has exactly two digits in common with a(3) = 10.
MATHEMATICA
a[1]=1; a[n_]:=a[n]=(k=1; While[MemberQ[Array[a, n-1], k]||Total[Count[IntegerDigits@a[n-1], #]&/@IntegerDigits@k]!=2, k++]; k); Array[a, 65] (* Giorgos Kalogeropoulos, Jan 12 2022 *)
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) != 2: k += 1
an, target = k, str(k)
seen.add(an)
while mink in seen: mink += 1
print(list(islice(agen(), 81))) # Michael S. Branicky, Jan 10 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rodolfo Kurchan, Jan 10 2022
STATUS
approved