def line_segment_intersection(p1, p2, p3, p4):
    """
    - Compute the intersect of two line segments if exists
    - Input:
        - p1, p2 (two end points of line segment 1; L1)
        - p3, p4 (two end points of line segment 2; L2)
    - Output:
        - (px, py) the intersect of two segments L1 and L2 if exists
        - None otherwise.
    """

    d = (p2[0] - p1[0]) * (p4[1] - p3[1]) - (p2[1] - p1[1]) * (p4[0] - p3[0])
    if d == 0.0:
        return None

    intersect = [0.0, 0.0]
    u = ((p3[0] - p1[0]) * (p4[1] - p3[1]) - (p3[1] - p1[1]) * (p4[0] - p3[0])) / d
    v = ((p3[0] - p1[0]) * (p2[1] - p1[1]) - (p3[1] - p1[1]) * (p2[0] - p1[0])) / d
    if u < 0.0 or u > 1.0 or v < 0.0 or v > 1.0:
        return None

    px = p1[0] + u * (p2[0] - p1[0])
    py = p1[1] + u * (p2[1] - p1[1])
    if px == p1[0] and py == p1[1] or \
       px == p2[0] and py == p2[1] or \
       px == p3[0] and py == p3[1] or \
       px == p4[0] and py == p4[1]:
       return None

    return (px, py)