Svoboda | Graniru | BBC Russia | Golosameriki | Facebook
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A123895 Restricted growth string for the (decimal expansion of the) number n. 4
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 11, 12, 12, 12, 12, 12, 12, 12, 12, 10, 12, 11, 12, 12, 12, 12, 12, 12, 12, 10, 12, 12, 11, 12, 12, 12, 12, 12, 12, 10, 12, 12, 12, 11, 12, 12, 12, 12, 12, 10, 12, 12, 12, 12, 11, 12, 12, 12, 12, 10, 12, 12, 12, 12, 12, 11, 12, 12 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,11
COMMENTS
Write n in base 10 prefixed with a 0. Read this string from left to right. Write a 0 each time you see the first distinct digit (which is 0), write a 1 each time you see the second distinct digit, write a 2 each time you see the third distinct digit and so on. Finally, delete the leading 0's.
REFERENCES
D. E. Knuth, The Art of Computer Programming, vol. 4A, Combinatorial Algorithms, Section 7.2.1.5, p. 432, Problems 4 and 5.
LINKS
EXAMPLE
To find a(66041171): 066041171 -> 011023343 -> 11023343.
MAPLE
read("transforms"):
A123895 := proc(n)
local dgs, Lmap, idx, dig, pos, Lredu ;
dgs := [op(convert(n, base, 10)) , 0];
Lmap := [] ;
for idx from -1 to -nops(dgs) by -1 do
dig := op(idx, dgs) ;
if not member(dig, Lmap) then
Lmap := [op(Lmap), dig] ;
end if;
end do:
Lredu := [] ;
for idx from -1 to -nops(dgs) by -1 do
member(op(idx, dgs), Lmap, 'pos') ;
Lredu := [op(Lredu), pos-1] ;
end do:
digcatL(Lredu) ;
end proc:
seq(A123895(n), n=0..60) ; # R. J. Mathar, Dec 09 2015
MATHEMATICA
f[n_] := Block[{d = Prepend[IntegerDigits@ n, 0], a, b, w}, b = DeleteDuplicates@ d; a = Range[0, Length@ b]; w = FromDigits@ Flatten[Part[a, FirstPosition[b, #]] & /@ d]; w]; Table[f@ n, {n, 0, 67}] (* Michael De Vlieger, Dec 09 2015, Version 10 *)
PROG
(VBA)
Public Function RestrictedGrowthString(ByVal x As String) As String
Dim i As Long
Dim dig As Integer
Dim pos As Long
For i = 1 To Len(x)
If Mid(x, i, 1) = "0" Then
RestrictedGrowthString = RestrictedGrowthString & "0"
Else
pos = InStr(x, Mid(x, i, 1))
If pos = i Then
dig = dig + 1
RestrictedGrowthString = RestrictedGrowthString &
Format(dig)
Else
RestrictedGrowthString = RestrictedGrowthString &
Mid(RestrictedGrowthString, pos, 1)
End If
End If
Next i
End Function
CROSSREFS
Sequence in context: A333722 A299981 A347180 * A147519 A303657 A342367
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Nov 20 2006
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 2 03:12 EDT 2024. Contains 374821 sequences. (Running on oeis4.)