From 3540ea41d53e17be714634bbe410986728f5de09 Mon Sep 17 00:00:00 2001 From: Kiri Date: Sun, 15 Jun 2025 07:34:34 -0700 Subject: [PATCH] Added missing thing. --- difftest.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 difftest.py diff --git a/difftest.py b/difftest.py new file mode 100644 index 0000000..ad84eb3 --- /dev/null +++ b/difftest.py @@ -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) +