OFFSET
0,3
COMMENTS
This sequence is a self-inverse permutation of the nonnegative integers.
LINKS
FORMULA
a(10*n) = 10*a(n).
EXAMPLE
For n = 1024:
- we have two runs of consecutive nonzero digits: "1" and "24",
- the reverse of "1" is "1", that of "24" is "42",
- so a(1024) = 1042.
PROG
(Perl) sub a { my $v = shift; $v =~ s/[1-9]+/reverse($&)/ge; return $v; }
(Python)
from itertools import groupby
def A352152(n): return int(''.join(''.join(list(g) if k else list(g)[::-1]) for k, g in groupby(str(n), key=lambda x:x =='0'))) # Chai Wah Wu, Mar 08 2022
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Mar 06 2022
STATUS
approved