Algorithms to stack boxes