Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -1,4 +1,4 @@
|
|||
def ld(a, b, mx=-1):
|
||||
def ld(a, b, mx=-1):
|
||||
def result(d): return d if mx < 0 else False if d > mx else True
|
||||
|
||||
if a == b: return result(0)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
>>> from functools import lru_cache
|
||||
>>> @lru_cache(maxsize=4095)
|
||||
def ld(s, t):
|
||||
if not s: return len(t)
|
||||
if not t: return len(s)
|
||||
if s[0] == t[0]: return ld(s[1:], t[1:])
|
||||
l1 = ld(s, t[1:])
|
||||
l2 = ld(s[1:], t)
|
||||
l3 = ld(s[1:], t[1:])
|
||||
return 1 + min(l1, l2, l3)
|
||||
if not s: return len(t)
|
||||
if not t: return len(s)
|
||||
if s[0] == t[0]: return ld(s[1:], t[1:])
|
||||
l1 = ld(s, t[1:])
|
||||
l2 = ld(s[1:], t)
|
||||
l3 = ld(s[1:], t[1:])
|
||||
return 1 + min(l1, l2, l3)
|
||||
|
||||
>>> print( ld("kitten","sitting"),ld("rosettacode","raisethysword") )
|
||||
3 8
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue