In a game of English eight-ball pool, a set of 15 balls are arranged or 'racked' in the shape of an equilateral triangle. In order for the balls to be racked fairly, they must be arranged like so:
......R.....
.....YR.....
.....RBY....
....YRYR....
....RYYRY...
R = Red
Y = Yellow
B = Black
Challenge
As a keen player of the game, I often consider what is the fastest way I could potentially rack a set of balls after dumping them in a random arrangement inside a triangle. I would then attempt to swap one pair of balls at a time until I have a valid rack.
I noticed that depending on how the balls were arranged before sorting, It could be quicker to sort the balls and then finish by rotating the triangle 120° in either direction.
With this in mind, considering every possible combination that the balls could randomly be arranged, what would be the most moves required to create any one of the valid racks as shown below?
Valid Racks
The red and yellow arrangement of balls can be inverted and as the rack is a equilateral triangle it has a rotational symmetry of 3, Therefore there are 6 possible valid solutions:
In theory, reflecting the pattern would create an equally fair racking arrangement, however it would not be a valid rack within World Rules.
Rules
- For the purpose of this puzzle, a move is only considered to be the act of swapping any two balls.
- The act of rotating the entire rack after sorting is not considered a move.
Note
For American pool players the distinction between yellows and reds can be considered the same as 'spots and stripes'.