Question

There are two boxes, A1×B1×C1 and A2×B2×C2 are size of boxes. Define if it is possible...

There are two boxes, A1×B1×C1 and A2×B2×C2 are size of boxes. Define if it is possible to totally cover one box in the another. (Hint: 1x1x1 can be covered by 2x1x1 box)
Input format
A1, B1, C1, A2, B2, C2.
Output format
The program should bring out one of the following lines:
Boxes are equal, if the boxes are the same,
the first box is smaller than the second one, if the first box can be put in the second,
the first box is larger than the second one, if the second box can be put in the first, Boxes are incomparable, in all other cases

Homework Answers

Answer #1
import numpy as np

def fit(inner_dims, outer_dims):
    inner_dims.sort()
    outer_dims.sort()
    x1, y1, z1 = inner_dims
    x2, y2, z2 = outer_dims
    
    # Volume Test
    
    inner_volume = x1 * y1 * z1
    outer_volume = x2 * y2 * z2    
    if inner_volume > outer_volume:
        return False
        
    # Edge Test
    
    diffs = np.greater_equal(outer_dims, inner_dims)
    if np.all(diffs):
        return True

    # Rotation Test
    
    inner_perms = [(x1, y1, z1), (x1, z1, y1), (z1, y1, x1)]
    outer_perms = [(x2, y2, z2), (x2, z2, y2), (z2, y2, x2)]
    
    for i, j in zip(inner_perms, outer_perms):
        if rotation_test(i, j):
            return True

    # Diagonal Test
    
    diag = np.sqrt(x2**2 + y2**2 + z2**2)
    if x1 + y1 + z1 <= diag:
        return True
                
    return False

def rotation_test(inner_dims, outer_dims):
    x1, y1, z1 = inner_dims
    x2, y2, z2 = outer_dims
    diag = np.sqrt(x2**2 + y2**2)
    if x1 + y1 <= diag and z1 <= z2:
        return True
    else:
        return False

def main():
  n = 3 
  first = []
  second = []
# iterating till the range 
  for i in range(0, n): 
    ele = int(input()) 
    first.append(ele)
  for i in range(0, n): 
    ele = int(input()) 
    second.append(ele) 
  # first = [1,1,1]
  # second = [2,2,2]
  first.sort()
  second.sort()
  if first == second:
    print("Boxes are of same size")
  elif fit(first,second):
    print("Box 1 fits in Box 2")
  elif fit(second,first):
    print("Box 2 fits in Box 2")
  else:
    print("Boxes are incomparable")
  
main()

please comment in case of doubt, please upvote the solution

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
If the determinant of the 3x3 matrix [2c1 -2c2 2c3; a1+6c1 -a2-6c2 a3+6c3; -b1 b2 -b3]...
If the determinant of the 3x3 matrix [2c1 -2c2 2c3; a1+6c1 -a2-6c2 a3+6c3; -b1 b2 -b3] is -16, what is the determinant of the 3x3 matrix [a1 b1 c1; a2 b2 c2; a3 b3 c3]?
Show with graphs. In a two country model with two goods and one factor, a1=a2*=1, a2=a1*=2,...
Show with graphs. In a two country model with two goods and one factor, a1=a2*=1, a2=a1*=2, L=L*=300, C2/C1=C2*/C1*=2; where a1 and a2 are quantities of labour input per unit of output for goods 1 and 2, respectively, in home country; L is the endownment of labour at home; C1 and C2 are the consumption levels of the first and second goods, respectively, in the home country; and asterisks indicate the corresponding variables of the foreign country. For each good, what...
A four-input (A1, A2, B1, B2) and two-output (Y1, Y2) “BUT” gate has the following behavior:...
A four-input (A1, A2, B1, B2) and two-output (Y1, Y2) “BUT” gate has the following behavior: • Y1 is 1 if A1 and B1 are 1 but either A2 or B2 is 0 • Y2 is defined symmetrically a. Write logic expressions for Y1 and Y2 outputs of the BUT gate b. Draw the corresponding logic diagram using AND gates, OR gates, and inverters c. Write a behavioral-style Verilog model for the BUT gate
Let S be the set of all real circles, defined by (x-a)^2 + (y-b)^2=r^2. Define d(C1,C2)...
Let S be the set of all real circles, defined by (x-a)^2 + (y-b)^2=r^2. Define d(C1,C2) = √((a1 − a2)^2 + (b1 − b2)^2 + (r1 − r2)^2 so that S is a metric space. Prove that metric space S is NOT a complete metric space. Give a clear example. Describe points of C\S as limits of the appropriate sequences of circles, where C is the completion of S.
Wal-Mart Online Wal-Mart is one of the largest companies in America. It is definitely the largest...
Wal-Mart Online Wal-Mart is one of the largest companies in America. It is definitely the largest retailer, both in terms of the number of stores (8,970 worldwide in 2011) and the level of sales ($419 billion from the 2011 Annual Report). By pushing suppliers to continually reduce costs, Wal-Mart is known for pursuing low prices and the stores often attract customers solely in-terested in lower prices. With Wal-Mart’s expansion into groceries, the company has be-come the largest retail grocer in...
What are 4 key things you learned about the topic from reading their paper? How does...
What are 4 key things you learned about the topic from reading their paper? How does the topic relate to you and your current or past job? Critique the paper in terms of the organization and quality. Team 3 answer questions above. Part I In today’s world we see fear among people when dealing with sexual harassment. This leads to people not reporting sexual harassment. A misconception about sexual harassment is that it’s only about touching and forcing other people...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...
Discuss ethical issues that can be identified in this case and the mode of managing ethics...
Discuss ethical issues that can be identified in this case and the mode of managing ethics Enron finds itself in this case. How would you describe the ethical culture and levels of trust at Enron? Provide reasons for your assessment. THE FALL OF ENRON: A STAKEHOLDER FAILURE Once upon a time, there was a gleaming headquarters office tower in Houston, with a giant tilted "£"' in front, slowly revolving in the Texas sun. The Enron Corporation, which once ranked among...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • In order to conduct a hypothesis test for the population proportion, you sample 450 observations that...
    asked 2 minutes ago
  • Doctor’s Order: Vancomycin 500mg tab i po q12h X 7 days Available: Vancomycin 500mg tablets What...
    asked 15 minutes ago
  • Calculate the ΔG∘rxn for the reaction using the following information. 4HNO3(g)+5N2H4(l)→7N2(g)+12H2O(l) ΔG∘f(HNO3(g)) = -73.5 kJ/mol; ΔG∘f(N2H4(l))...
    asked 16 minutes ago
  • Question 03: Saturn Shoes (Pvt.) Ltd manufacture multi-style fashion boots for the residents of Missouri. Leather...
    asked 18 minutes ago
  • A highway with a design speed of 100 km/hr is designed with a sag curve connecting...
    asked 30 minutes ago
  • Shift Registers can be used for serial/parallel interface applications. True or false?
    asked 56 minutes ago
  • Scenario 1: To describe the instructors’ experience, the researcher records the year in which each instructor...
    asked 1 hour ago
  • develop a flowchart or pseudocode to check the prime numbers 1- below 100 what to do...
    asked 1 hour ago
  • Which of the following statements are true? I. The sampling distribution of ¯xx¯ has standard deviation...
    asked 1 hour ago
  • Which of the following methods of reporting cash flows provided by operating activities does the Financial...
    asked 1 hour ago
  • SITUATION 2: EFFECTIVE STRESS An engineer investigates a granular soil deposit, 4 meters thick, overlaying a...
    asked 1 hour ago
  • Suppose that R is a commutative ring and I is an ideal in R. Please prove...
    asked 1 hour ago