Five aligned points and some of the pairwise distances. Infer the relative positions! Given five points on a straight line such that their pairwise distances are 1,2,4, ..., 14,18,20 (after ordering), find the respective positions of the five points (relative to the furthest point on the left).
R

prop &lt;- function(num_points, first_distances, last_distances)
{
    last_point = max(last_distances)
    proposal = c(0, sort(sample(1:(last_point-1), num_points-2)), last_point)
    d = sort(dist(proposal))
    num_first_distances = length(first_distances)
    num_last_distances = length(last_distances)
    num_distances = length(d)
    if(all(d[1:num_first_distances]==first_distances)&amp;&amp;all(d[(num_distances-num_last_distances+1):num_distances]==last_distances))
    {
        print(proposal)
        return(TRUE)
    }
    else return(FALSE)
}

while(TRUE)
{
    if(prop(5, c(1,2,4), c(14,18,20))) break()
}


Here is the source of the problem and an algorithm with R which I used for inspiration.