Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #57 Nov 05 2024 12:13:40
%S 1,1,1,1,1,1,1,1,1,1,12,11,12,12,12,12,12,12,12,12,12,12,11,12,12,12,
%T 12,12,12,12,12,12,12,11,12,12,12,12,12,12,12,12,12,12,11,12,12,12,12,
%U 12,12,12,12,12,12,11,12,12,12,12,12,12,12,12,12,12,11,12
%N Replace each new digit in n with index 1, 2, ..., 9, 0 in order in which that digit appears in n, from left to right.
%C a(n) gives the canonical form which enumerates digits in order of their first occurrence in n, from left to right. a(n) uniquely defines the pattern of identical digits in n. - _Dmytro Inosov_, Jul 16 2024
%H David A. Corneth, <a href="/A358497/b358497.txt">Table of n, a(n) for n = 0..9999</a>
%H Dmytro S. Inosov and Emil Vlasák, <a href="https://arxiv.org/abs/2410.21427">Cryptarithmically unique terms in integer sequences</a>, arXiv:2410.21427 [math.NT], 2024. See pp. 3, 18.
%F a(a(n)) = a(n). - _Dmytro Inosov_, Jul 16 2024
%e n = 10 has 2 different digits; replace first encountered digit 1 -> 1, replace second digit 0 -> 2, therefore a(10) = 12.
%e n = 141 has 3 digits, but only 2 different ones; replace first encountered digit 1 -> 1, replace second encountered digit 4 -> 2, therefore a(141) = 121.
%t A358497[k_] := With[{pI = Values@PositionIndex@IntegerDigits@k}, MapIndexed[#1 -> Mod[#2[[1]], 10] &, pI, {2}] // Flatten // SparseArray // FromDigits]; (* _Dmytro Inosov_, Jul 15 2024 *)
%o (Python)
%o def A358497(n):
%o d,s,k = dict(),str(n),1
%o for i in range(len(s)):
%o if d.get(s[i],0) == 0:
%o d[s[i]] = str(k)
%o k = (k + 1)%10
%o s_t = list(s)
%o for i in range(len(s)):s_t[i] = d[s[i]]
%o return int(''.join(s_t))
%o print([A358497(i) for i in range(100)])
%o (Python)
%o def A358497(n):
%o s, c, i = str(n), {}, 49
%o for d in map(ord,s):
%o if d not in c:
%o c[d] = i
%o i += 1
%o return int(s.translate(c)) # _Chai Wah Wu_, Jul 09 2024
%o (PARI) a(n) = {if(n == 0, return(1)); my(d = digits(n), m = Map(), t = 0); for(i = 1, #d, if(mapisdefined(m, d[i]), d[i] = mapget(m, d[i]) , t++; if(t == 10, t = 0); mapput(m, d[i], t); d[i] = t ) ); fromdigits(d) } \\ _David A. Corneth_, Nov 23 2022
%Y Cf. A071159, A227362, A358615 (record high values).
%K nonn,base,easy
%O 0,11
%A _Gleb Ivanov_, Nov 19 2022