login
This site is supported by donations to The OEIS Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A248327 Levenshtein distance of n and its reversal in decimal representation, cf. A004086. 2
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 0, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 0, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 0, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 0, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 0, 2, 2, 1, 2, 2, 2, 2, 2 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,13

COMMENTS

a(n) = number of editing steps (replace, delete and insert) to transform n to A004086(n);

a(A002113(n)) = 0, a(10*A002113(n)) = 1 for n > 0;

a(A248336(n)) = n and a(m) != n for m < A248336(n).

LINKS

Reinhard Zumkeller, Table of n, a(n) for n = 0..10000

Haskell Wiki, Edit distance

WikiBooks: Algorithm Implementation, Levenshtein distance

Wikipedia, Levenshtein distance

PROG

(Haskell)

a248327 0 = 0

a248327 n = levenshtein (show n) (dropWhile (== '0') $ reverse $ show n)

levenshtein :: (Eq t) => [t] -> [t] -> Int

levenshtein us vs = last $ foldl transform [0..length us] vs where

   transform xs@(x:xs') c = scanl compute (x+1) (zip3 us xs xs') where

      compute z (c', x, y) = minimum [y+1, z+1, x + fromEnum (c' /= c)]

CROSSREFS

Cf. A004086, A002113, A248336.

Sequence in context: A052010 A138471 A102669 * A055098 A297035 A055178

Adjacent sequences:  A248324 A248325 A248326 * A248328 A248329 A248330

KEYWORD

nonn,base

AUTHOR

Reinhard Zumkeller, Oct 05 2014

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified October 17 08:36 EDT 2019. Contains 328107 sequences. (Running on oeis4.)