I have six boxes with different sizes. Two boxes are red, two boxes are blue and two boxes are green.
There is only one dimension that matters. Let $r$ and $r'$ be the size of red boxes. Similarly for $b$ and $b'$, and $g$ and $g'$.
I know that:
$\begin{align*} r + b + g &= 1\\ r' + b' + g' &= 1\\ r + r' &\le 1\\ b + b' &\le 1\\ g + g' &\le 1 \end{align*}$
I want to put boxes of size r, g and b in "line", one after the other. I also want to put r', b' and g' in line, one after the other. These two lines formed by the two sets of boxes are to be put in parallel, side by side, touching each other.
Example:
_____________________________________________
| | | |
| r | g | b |
|____________|_______________________|________|
| | | |
| g' | b' | r' |
|_______|_____________|_______________________|
Can I always (for all values of $r,r',g,g',b,b'$ respecting the conditions above) find an arrangement that does not have boxes of the same color touching each other (such as the one in the example above) ?
Thanks,
A
** EDIT: My original algorithm had a flaw, but it is now corrected
The layout I used is
Instead of a total width of 1, I made it 1000 so that I could better see the boxes on my screen. It can be converted back by dividing each box's width by 1000.
I came up with the following algorithm that arranges the boxes so that they do not touch.
I created a C# program to calculate random values respecting the conditions, apply the algorithm above, and display the result. (Note: The row with the largest box always displays on top (Row 1), even if the largest box was a prime.)
Here are some screenshots:
I ran a simulation with over 2 billion runs, and no counter-examples were found.