If $$A = (0, a_1, \ldots, a_{n-1})$$ is a tuple of $$n$$ points on a line segment in increasing order ($$0 < a_1 < \cdots < a_{n-1}$$), then $$\Delta A$$ denotes the collection of all pairwise distances between points in $$A$$. For example, if \[A = (0, 2, 4, 7)\] then \[ \Delta A = (7, 5, 4, 3, 2, 2, 0, 0, 0, 0, 2, 2, 3, 4, 5, 7) \] The turnpike problem asks us to reconstruct $$A$$ from $$\Delta A$$.
Write a function turnpike that takes a collection (a list or a tuple) of integers $$L$$. The function must return a set containing all tuples of integers $$A = (0, a_1, \ldots, a_{n-1})$$ with $$0 < a_1 < \cdots < a_{n-1}$$ such that $$\Delta A = L$$.
>>> turnpike((-10, -8, -7, -6, -5, -4, -3, -3, -2, -2, 0, 0, 0, 0, 0, 2, 2, 3, 3, 4, 5, 6, 7, 8, 10)) {(0, 2, 4, 7, 10), (0, 3, 6, 8, 10)}
Dakic T (2000). On the turnpike problem. Simon Fraser University, BC, Canada. 1
Lemke P, Skiena SS, Smith WD (2003). Reconstructing sets from interpoint distances. In Discrete and computational geometry (Springer, Berlin, Heidelberg), 597–631. 2
Lenstra AK, Lenstra HW, Lovász L (1982). Factoring polynomials with rational coefficients. Mathematische Annalen 261(4), 515–534. 3
Rosenblatt J, Seymour PD (1982). The structure of homometric sets. SIAM Journal on Algebraic Discrete Methods 3(3), 343–350. 4
Zhang Z (1994). An exponential example for a partial digest mapping algorithm. Journal of computational biology 1(3), 235–239. 5