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.
Suppose you are given a set S = {a1,a2,···,an} of tasks, where task ai requires pi...
Suppose you are given a set S = {a1,a2,···,an} of tasks, where task ai requires pi units of processing time to complete, once it has started. You have one computer on which to run these tasks, and the computer can run only one task at a time. Let ci be the completion time of task ai, that is, the time at which task ai completes processing. Your goal is to minimize the average completion time, that is, to minimize n1...
Please do the following in python: Write a program (twitter_sort.py) that merges and sorts two twitter...
Please do the following in python: Write a program (twitter_sort.py) that merges and sorts two twitter feeds. At a high level, your program is going to perform the following: Read in two files containing twitter feeds. Merge the twitter feeds in reverse chronological order (most recent first). Write the merged feeds to an output file. Provide some basic summary information about the files. The names of the files will be passed in to your program via command line arguments. Use...
You are coding a simple game called Pig. Players take turns rolling a die. The die...
You are coding a simple game called Pig. Players take turns rolling a die. The die determines how many points they get. You may get points each turn your roll (turn points), you also have points for the entire game (grand points). The first player with 100 grand points is the winner. The rules are as follows: Each turn, the active player faces a decision (roll or hold): Roll the die. If it’s is a: 1: You lose your turn,...
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...