def median(a, b, c):
    """
    Adapted from:
    https://stackoverflow.com/questions/17158667/minimum-no-of-comparisons-to-find-median-of-3-numbers
    """
    x = a - b
    y = b - c
    z = a - c

    if x * y > 0:
        return b
    if x * z > 0:
        return c
    
    return a