def hamming_distance(s1, s2):
    """Calculate the Hamming distance between two strings of equal lengths.
    Raise ValueError if strings are of unequal length.
    """
    if len(s1) != len(s2): raise ValueError('strings of unequal length')
    return sum(ch1 != ch2 for ch1, ch2 in zip(s1, s2))