# Lazy Box Sorting

In front of Louis there are 10 boxes containing different foods: tomatoes, (red) herrings, and bananas.

The boxes are arranged side by side in a line. Right next to the last box are three bigger containers extending this line. His job is to put these boxes into the containers, sorted by food. At his disposal: a crane which can only move horizontally and can pick up and put down one box at a time.

Louis wants to move the boxes a little as possible. Before doing anything, he makes a simplified drawing of his situation, to figure out the best way to move them on paper.

Using the simplified picture, what is the smallest overall travel distance covered by all boxes that he can achieve?

Addition is commutative --@Punintended. Every item needs to move from its original position to the first spot in the containers. Then every item needs to move from the first spot in the containers to its correct spot. From this decomposition we see that it does not matter which banana goes to which banana spot, etc. To move all items to the first spot, it takes 1+2+3+4+...+10 = 10 * 11/2 = 55. To move every items from the first spot to its correct spot, it takes 0+1+2+3+...+9 = 9*10/2 = 45. The total distance traveled is 55+45 = 100.