def chooseOptimalXValue(keypoints, samples):
    """
    This method returns the optimal x value to sample next, given
    an existing set of samples.
    
    Param(s):
        keypoints:  a list of tuples of x,y coordinate pairs.
        samples:    a 2D list of y values per x value.
                    E.g., [ [y,y,y,y,y], [y,y], [y,y,y,y] ]
                    The indices are the x values.
    Returns:
        minSampsX:  an int, representing the x coordinate 
                    that has been sampled the least, so far. 
    """       
    # The x coordinate of the keypoint that has been sampled the least.
    minSampsX = None
    # The quantity of samples at minSampsX.
    minSamps  = None
    
    # Iterate over keypoints.
    for kpIdx in range(len(keypoints)):
        # x coordinate at a keypoint.
        x = keypoints[kpIdx][0]
        # The quantity of samples at the keypoint.
        sampQuant = len(samples[x])
        # Identify the least sampled keypoint.
        if minSamps is None or sampQuant < minSamps:
            minSampsX = x
            minSamps  = sampQuant
    # Return the x coordinte (int) of the least sampled keypoint.        
    return minSampsX