Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Can the box fit into another box?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me with this task.
Very hard Task.

So I want to get how does it work, not just code without comments

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 which box can be put inside another box. You can rotate both boxes as you want.


Input contains 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.



If the sizes of the boxes are equal, output "Box 1 = Box 2".

If the first box can be put inside the second box, output "Box 1 < Box 2".

If the second box can be put inside the first box, output "Box 1 > Box 2".

If none of the boxes can be put inside the other box, output "Incomparable".
 
Saloon Keeper
Posts: 6768
64
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
 
Marshal
Posts: 67464
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
As Carey has hinted, it isn't quite as hard as that website suggested.
 
Marshal
Posts: 24950
61
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But Carey's suggestion assumes a limited version of "rotate". For example a 14x1x1 box can fit inside an 11x11x1 box if you rotate it correctly. Given that version of "rotate", this is not at all easy.
 
Carey Brown
Saloon Keeper
Posts: 6768
64
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting observation. I see you're thinking outside the box.

I would be surprised if that was what the framers of the question had in mind but the link to the problem has timed out and is no longer available to verify. If your theory is correct, then yes, that would be a pretty sticky problem to solve and would be beyond my geometry skills.
 
Paul Clapham
Marshal
Posts: 24950
61
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the feeling that the full three-dimensional version of my theory is an unsolved mathematical problem -- at least I sort of recall reading that figuring out whether a given rectangular block can be moved around a corner in a given rectangular corridor is unsolved, which is probably more complicated. So I think that your simpler theory is the one meant to be solved.
 
Bartender
Posts: 725
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general, it is easier to solve if you rotate both boxed so that they lie flat in the x-y plane, where it is easier to calculate the volume of each. Then see if the one with the smaller volume will fit in the larger box.
 
Dinner will be steamed monkey heads with a side of tiny ads.
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!