I understand the dynamic programming solution to the Box Stacking problem, which tries to find the maximum possible length of a stack that can be formed by a given set of boxes, that can be rotated in any direction, such that the lower box is always lesser in width and length as compared to a box that is higher in the stack.
However, I haven't been able to understand why only 3 orientations are required for every box. According to me, the number of orientations should be 6. That is, for each of the three dimensions taken as height, you should have two combinations.
An online resource shows the following as the method to create the three orientations(2 rotations) of the original box.
/* Create an array of all rotations of given boxes
For example, for a box {1, 2, 3}, we consider three
instances{{1, 2, 3}, {2, 1, 3}, {3, 1, 2}} */
Box rot[3*n];
int index = 0;
for (int i = 0; i < n; i++)
{
// Copy the original box
rot[index] = arr[i];
index++;
// First rotation of box
rot[index].h = arr[i].w;
rot[index].d = max(arr[i].h, arr[i].d);
rot[index].w = min(arr[i].h, arr[i].d);
index++;
// Second rotation of box
rot[index].h = arr[i].d;
rot[index].d = max(arr[i].h, arr[i].w);
rot[index].w = min(arr[i].h, arr[i].w);
index++;
}
So, For example, for a box {1, 2, 3}, the three orientations would be
1 2 3
2 1 3
3 1 2
But according to me, the orientations should be
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
I understand that my extra three combinations are due to alternating length and width between them keeping the height same. So, whereas I conside 1 2 3 and 1 3 2 to be different, the original algorithm considers them to be the sam.
However, I feel that, in this problem h,l,w and h,w,l, should be treated as two separate orientations since a box say, l=3,w=4,h=5 could be stacked above a box say, l=4,w=5,h=6, but not above a box l=5,w=4,h=6