There are \(10\) containers arranged in a row on a table. On the bottom of each container there is one of the following letters:
A, B, C, D, E, F, G, H, I, J
Each letter occurs exactly once.
Anneke has written the following algorithm to find a particular letter: Pick up the leftmost container and look on the bottom. If it’s the letter you’re looking for, put the container back down and stop. Otherwise, pick up the next container and look on the bottom. If it’s the letter you’re looking for, put the container back down, swap it with the container to its left, and stop. If it is not the letter you’re looking for, pick up the next container and repeat this until you find the letter you’re looking for.
For example, suppose the containers were in the following order:
G, B, F, J, A, I, E, H, C, D
Anneke uses her algorithm to find the letter E. She looks at the first \(6\) containers and returns each of them to the table. When she looks at the seventh container and sees that it is the E, she swaps containers E and I. So to locate the letter E, Anneke looked at \(7\) containers, and the containers would now be in the following order.
G, B, F, J, A, E, I, H, C, D
Suppose Anneke now wants to find the letter J. She looks at the G, B, and F and puts them back down. She then looks at the fourth container, sees the J, and swaps containers F and J. The containers would now be in the following order.
G, B, J, F, A, E, I, H, C, D
After searching for the E and the J, Anneke has looked at a total of \(7+4=11\) containers.
If the \(10\) containers begin in some unknown order and Anneke uses her algorithm to search for each of the ten letters exactly once, what is the maximum possible number of containers that Anneke picks up to look on the bottom?
This problem was inspired by a past Beaver Computing Challenge (BCC) problem.