  The traveling-salesman problem is one of the most studied combinatorial
optimization problems, because of the simplicity in its statement and the
difficulty in its solution. We study the traveling salesman problem when the
positions of the cities are chosen at random in the unit interval and the cost
associated to the travel between two cities is their distance elevated to an
arbitrary power $p\in \mathbb{R}$. We characterize the optimal cycle and
compute the average optimal cost for every number of cities when the measure
used to choose the position of the cities is flat and asymptotically for large
number of cities in the other cases. We also show that the optimal cost is a
self-averaging quantity, and we test our analytical results with extensive
simulations.
