A milling machine in a manufacturing facility has a tool change system.

A milling machine in a manufacturing facility has a tool change system. The tool changer holds n tools and some duplicate tools may be included. The operator must move through the tools one at a time, either moving left or right. The tool changer is circular, so when the last tool in the tools array is reached in either direction, the next tool is at the other end of the array.
Given the name of the next tool needed, determine the minimum number of left or right moves to reach it.