def find_maxmin_ratios(lines):
    lines = [row.split() for row in lines]
lines = [(int(row[0]), row[1]) for row in lines]
lines = groupby(sorted(lines), lambda x: x[0])
group_minmax = dict()
for index, group in lines:
    strings = list(group)
if len(strings) > 1:
    max_similarity = 1
min_similarity = 0
for line1, line2 in combinations(strings, 2):
    s = difflib.SequenceMatcher(None, line1[1], line2[1])
max_similarity = s.ratio() if s.ratio() < max_similarity else max_similarity
min_similarity = s.ratio() if s.ratio() > min_similarity else min_similarity
group_minmax[index] = 1 - max_similarity, 1 - min_similarity
return group_minmax
Calculate the greatest distance between any two strings in a group, using Python