cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A358497 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.

This page as a plain text file.
%I A358497 #57 Nov 05 2024 12:13:40
%S A358497 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 A358497 12,12,12,12,12,12,12,11,12,12,12,12,12,12,12,12,12,12,11,12,12,12,12,
%U A358497 12,12,12,12,12,12,11,12,12,12,12,12,12,12,12,12,12,11,12
%N A358497 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 A358497 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 A358497 David A. Corneth, <a href="/A358497/b358497.txt">Table of n, a(n) for n = 0..9999</a>
%H A358497 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 A358497 a(a(n)) = a(n). - _Dmytro Inosov_, Jul 16 2024
%e A358497 n = 10 has 2 different digits; replace first encountered digit 1 -> 1, replace second digit 0 -> 2, therefore a(10) = 12.
%e A358497 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 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 A358497 (Python)
%o A358497 def A358497(n):
%o A358497     d,s,k = dict(),str(n),1
%o A358497     for i in range(len(s)):
%o A358497         if d.get(s[i],0) == 0:
%o A358497             d[s[i]] = str(k)
%o A358497             k = (k + 1)%10
%o A358497     s_t = list(s)
%o A358497     for i in range(len(s)):s_t[i] = d[s[i]]
%o A358497     return int(''.join(s_t))
%o A358497 print([A358497(i) for i in range(100)])
%o A358497 (Python)
%o A358497 def A358497(n):
%o A358497     s, c, i  = str(n), {}, 49
%o A358497     for d in map(ord,s):
%o A358497         if d not in c:
%o A358497             c[d] = i
%o A358497             i += 1
%o A358497     return int(s.translate(c)) # _Chai Wah Wu_, Jul 09 2024
%o A358497 (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 A358497 Cf. A071159, A227362, A358615 (record high values).
%K A358497 nonn,base,easy
%O A358497 0,11
%A A358497 _Gleb Ivanov_, Nov 19 2022