class Box:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
self.cube = (x * y * z)
big = Box(100, 120, 150)
small = Box(4,9,2)
I have these 2 instances of my Box class. I am trying to find how many, 'small boxes' could fit into the 'large box'. I know the optimal solution for the example given is 25,000, which is lowered to 24,750, given that I am stacking all boxes with the same orientation. There are 6 orientations possible.
I know that equation 4 gives me the 24,750, however I can't return my new 'best' small x,y,z values (which should be (9,4,2) instead of (4,9,2).
I have tried adding return statements to each equation and reverse engineering it with sympy e.g.
x, y, z = symbols('x y z')
eq1 = solve( (100 / x) * (120 / y) * (150 / z) ,24750)
print(eq1)
which return an empty array.
This is the function I am currently using to evaluate the 6 orientations.
def best(smaller, bigger):
new_x = smaller.x
new_y = smaller.y
new_z = smaller.z
equation1 = math.floor((bigger.x / new_x)) * math.floor((bigger.y / new_y)) * math.floor((bigger.z / new_z))
equation2 = math.floor((bigger.x / new_x)) * math.floor((bigger.y / new_z)) * math.floor((bigger.z / new_y))
equation3 = math.floor((bigger.x / new_y)) * math.floor((bigger.y / new_z)) * math.floor((bigger.z / new_x))
equation4 = math.floor((bigger.x / new_y)) * math.floor((bigger.y / new_x)) * math.floor((bigger.z / new_z))
equation5 = math.floor((bigger.x / new_z)) * math.floor((bigger.y / new_x)) * math.floor((bigger.z / new_y))
equation6 = math.floor((bigger.x / new_z)) * math.floor((bigger.y / new_y)) * math.floor((bigger.z / new_x))
list_of_equations = [equation1, equation2, equation3, equation4, equation5, equation6]
max_item = max(list_of_equations)
print(max_item)
I think adding a return statement to the equations individually doesn't work because it evaluates as the answer not the equation. I am still quite new to Python so any tips or pointers would be greatly appreciated, thanks. :)