Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Compare string, count diffs, look for substrings else return count of diffs solution in Clear category for String Conversion by kkkkk
def steps_to_convert(line1, line2):
diffs = [i for i, (c1, c2) in enumerate(zip(line1, line2)) if c1 != c2]
if not diffs or line1 in line2:
# Either the lines are the same or one line is a subset of the other.
# If the lengths are different, then the steps needed to insert or
# delete letters is the lengths difference.
return abs(len(line1) - len(line2))
return len(diffs)
Feb. 28, 2017
Comments: