def getSegmentsFromXIntersections(xIntersections, y):
 segments = []
 end = len(xIntersections)
 if ((len(xIntersections) % 2) == 1):
  end -= 1
 for xIntersectionIndex in xrange(0, end, 2):
  firstX = xIntersections[xIntersectionIndex]
  secondX = xIntersections[(xIntersectionIndex + 1)]
  if (firstX != secondX):
   segments.append(getSegmentFromPoints(complex(firstX, y), complex(secondX, y)))
 return segments

def getSegmentsFromXIntersections ( xIntersections , y ) : segments = [ ] end = len ( xIntersections ) if ( ( len ( xIntersections ) % 2 ) == 1 ) : end -= 1 for xIntersectionIndex in xrange ( 0 , end , 2 ) : firstX = xIntersections [ xIntersectionIndex ] secondX = xIntersections [ ( xIntersectionIndex + 1 ) ] if ( firstX != secondX ) : segments . append ( getSegmentFromPoints ( complex ( firstX , y ) , complex ( secondX , y ) ) ) return segments
get endpoint segments from the x intersections .