login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A081355
Levenshtein distance between n and n^2 in decimal representation.
6
0, 0, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 2, 2, 3, 2, 3, 1, 2, 2, 2, 3, 2, 2, 3, 4, 4, 3, 3, 3, 4, 4, 3, 3, 4, 3, 4, 3, 3, 4, 4, 3, 2, 3, 4, 4, 4, 3, 3, 4, 4, 4, 2, 3, 4, 3, 4, 3, 3, 4, 3, 3, 3, 3, 4, 3, 3, 3, 2, 4, 3, 4, 3, 3, 3, 3, 4, 3, 3, 4, 4, 3, 3, 3, 4, 4, 4, 2, 2, 3, 3, 3, 2, 2, 3, 3, 3
OFFSET
0,5
LINKS
Michael Gilleland, Levenshtein Distance. [It has been suggested that this algorithm gives incorrect results sometimes. - N. J. A. Sloane]
MATHEMATICA
levenshtein[s_List, t_List] := Module[{d, n = Length@s, m = Length@t}, Which[s === t, 0, n == 0, m, m == 0, n, s != t, d = Table[0, {m + 1}, {n + 1}]; d[[1, Range[n + 1]]] = Range[0, n]; d[[Range[m + 1], 1]] = Range[0, m]; Do[ d[[j + 1, i + 1]] = Min[d[[j, i + 1]] + 1, d[[j + 1, i]] + 1, d[[j, i]] + If[ s[[i]] === t[[j]], 0, 1]], {j, m}, {i, n}]; d[[ -1, -1]] ]];
f[n_] := levenshtein[IntegerDigits[n], IntegerDigits[n^2]]; Table[f[n], {n, 0, 104}] (* Robert G. Wilson v, Jan 25 2006 *)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Reinhard Zumkeller, Mar 18 2003
STATUS
approved

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy