Skip to content

Instantly share code, notes, and snippets.

@vgmoose
Created June 18, 2022 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgmoose/5a2a86aeddf2ab097df43c3324a54d72 to your computer and use it in GitHub Desktop.
Save vgmoose/5a2a86aeddf2ab097df43c3324a54d72 to your computer and use it in GitHub Desktop.
s1 = "@Jam this campaign is actually made by gad, is he aware that's going out to all tempers?".lower()
s2 = "@jm it has a new logo is probably why you didn't recognize it!".lower()
x, y = 0, 0
out = ""
while x < len(s1) and y < len(s2):
print(out)
if s1[x] == s2[y]:
out += s1[x]
else:
out += "*"
# time to find the "nearest" collision in either string
s1_seen = {}
s2_seen = {}
xx, yy = x, y
isFound = False
while xx < len(s1) and yy < len(s2):
s1_seen[s1[xx]] = xx
s2_seen[s2[yy]] = yy
interset = s2_seen.keys() & s1_seen.keys()
if len(interset) > 0:
if len(interset) > 1:
print("zoinks scoob, two possibilities")
cur = interset.pop()
x = s1_seen[cur]
y = s2_seen[cur]
print("updating", x, y)
isFound = True
break
xx += 1
yy += 1
if isFound:
continue
else:
print("jinkies, no match!")
x += 1
y += 1
print(out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment