Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
def setup():
|
||||
println(distance("kitten", "sitting"))
|
||||
|
||||
def distance(a, b):
|
||||
costs = []
|
||||
for j in range(len(b) + 1):
|
||||
costs.append(j)
|
||||
for i in range(1, len(a) + 1):
|
||||
costs[0] = i
|
||||
nw = i - 1
|
||||
for j in range(1, len(b) + 1):
|
||||
cj = min(1 + min(costs[j], costs[j - 1]),
|
||||
nw if a[i - 1] == b[j - 1] else nw + 1)
|
||||
nw = costs[j]
|
||||
costs[j] = cj
|
||||
|
||||
return costs[len(b)]
|
||||
Loading…
Add table
Add a link
Reference in a new issue