Added missing thing.

This commit is contained in:
Kiri 2025-06-15 07:34:34 -07:00
parent eaae56627b
commit 3540ea41d5

44
difftest.py Normal file
View File

@ -0,0 +1,44 @@
import difflib
s1 = "1234asdffooMOO"
s2 = "asdfbarMOOwhatever"
# s1 = "asdffoo"
# s2 = "asdffooMOO"
def onestepchange(start, dest):
ret = ""
for i, s in enumerate(difflib.ndiff(start, dest)):
# print(i)
# print(s)
if s[0] == '-':
return ret + start[i+1:]
if s[1] == '+':
return ret + s[-1] + start[i:]
ret = ret + s[-1]
if len(ret) > len(start):
return ret
if ret[i] != start[i]:
return ret + start[i:]
return ret
n = s1
while n != s2:
print(n)
n = onestepchange(n, s2)
print(n)
# for i, s in enumerate(difflib.ndiff(s1, s2)):
# print(i)
# print(s)