List <box> getAllCombinationsOfBoxes(List <box> boxList) { //To generate all the rotations of the box we will need another list with size if boxList.Count * 3 List <box> AllRotationCombinations = new List <box>(); foreach (box obj in boxList) { // To generate Combination Take (L,W,H) as L,then Max of (W,H if L taken as 1st arg) and Min (W,H if L taken as 1st arg) box comb1 = new box(Math.Max(obj.W, obj.H), Math.Min(obj.W, obj.H), obj.L); //Calculate area comb1.area = comb1.L * comb1.W; box comb2 = new box(Math.Max(obj.L, obj.H), Math.Min(obj.L, obj.H), obj.W); //Calculate area comb2.area = comb2.L * comb2.W; box comb3 = new box(Math.Max(obj.W, obj.L), Math.Min(obj.W, obj.L), obj.H); //Calculate area comb3.area = comb3.L * comb3.W; AllRotationCombinations.Add(comb1); AllRotationCombinations.Add(comb2); AllRotationCombinations.Add(comb3); } return(AllRotationCombinations); }
public box_stacking_problem() { List <box> boxList = new List <box>();; box b1 = new box(4, 6, 7); box b2 = new box(1, 2, 3); box b3 = new box(4, 5, 6); box b4 = new box(10, 12, 32); boxList.Add(b1); boxList.Add(b2); boxList.Add(b3); boxList.Add(b4); SolveBoxDP(boxList); }