Boxes

Report a typo

There are two boxes on the table. The first box has a size of X1 x Y1 x Z1, and the second box has a size of X2 x Y2 x Z2.
You need to determine whether one of the boxes can be put inside the other. It should go in without sticking out.
To place one box within another, you can shift and rotate both boxes as you want. This means that the order of integer inputs for a box is not important while comparing the boxes.

Important: two equally sized boxes cannot be placed inside one another. See the third test case as an example of how the edge case should be treated.

Input consists of two lines:

  • the first line contains numbers X1, Y1, Z1;

  • the second line contains numbers X2, Y2, Z2.

All numbers are integers and greater than 0.

Output:

  • "Box 1 < Box 2", if the first box can be put inside the second box ;

  • "Box 1 > Box 2", if the second box can be put inside the first box;

  • otherwise, output "Incompatible".

Tip: One box can be placed inside the other only if it is strictly smaller by all three dimensions. It does not necessarily mean that boxes cannot have one equal side, as you can rotate them.

Sample Input 1:

1 2 3
5 6 4

Sample Output 1:

Box 1 < Box 2

Sample Input 2:

2 9 4
3 8 1

Sample Output 2:

Box 1 > Box 2

Sample Input 3:

1 3 7
2 8 3

Sample Output 3:

Incompatible
Write a program in Java 17
import java.util.*;

public class Main {
public static void main(String[] args) {
// write your code here
}
}
___

Create a free account to access the full topic