Cubing - Boxes on a pallet

I’d like to find best fill on a pallet. If i know the dimensions of the boxes and the pallet, can I workout teh optimum fill, if I can vary the orientation in 2 of the dimensions?