from functools import reduce
return len(set(flattened)) == len(flattened)

def getscore(segments):
    """
    p = 1.0
    for segment in segments:
      p *= segment_scores[segment]
    return p
    better way:
    """
return reduce(operator.mul, [segment_scores[segment] for segment in segments])
Establishing highest score for a set of combinations