Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
non-zip_longest version solution in Clear category for Fuzzy String Matching by dan_rue
def fuzzy_string_match(str1: str, str2: str, threshold: int) -> bool:
s_min, s_max = min(len(str1), len(str2)), max(len(str1), len(str2)) # length of shorter and longer string
# difference in length are considered non-matching characters
diffs = s_max - s_min
for i in range(s_min):
# compare char at position i, add to diffs (since True is considered 1 and False is considered 0
diffs += str1[i] != str2[i]
return diffs <= threshold
Feb. 24, 2024