def jaccard(a, b):
    """
    Calculate the jaccard coefficient of two sets.
    """

    (a, b) = (set(a), set(b))
    n = len(a & b) # intersection
    d = len(a | b) # union
    if d == 0:
        return 1
    return n / d