Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function parallelepipedSpace(a, b, c) {
- return 2 * (a * b + b * c + c * a);
- }
- function parallelepipedVolume(a, b, c) {
- return a * b * c;
- }
- function isEqual(a, b, c, a1, b1, c1) {
- return (parallelepipedSpace(a, b, c) === parallelepipedSpace(a1, b1, c1)) &&
- (parallelepipedVolume(a, b, c) === parallelepipedVolume(a1, b1, c1));
- }
- function isBiggerBox(a, b, c, a1, b1, c1) {
- var box1 = [a, b, c];
- var box2 = [a1, b1, c1];
- for (var i = 0; i < box1.length; i++) {
- if ((box1[0] >= box2[0]) && (box1[1] >= box2[1]) && (box1[2] >= box2[2])) {
- return true;
- }
- box1 = [box1[1], box1[2], box1[0]];
- }
- return false;
- }
- //(1st box 1st side, 1st box 2st side, 1st box 3st side, 2st box 1st side, 2st box 2st side, 2st box 3st side)
- function comparison(a, b, c, a1, b1, c1) {
- if (isEqual(a, b, c, a1, b1, c1)) {
- return "Boxes are equal";
- } else if (parallelepipedVolume(a, b, c) > parallelepipedVolume(a1, b1, c1) && isBiggerBox(a, b, c, a1, b1, c1)) {
- return "The first box is larger than the second one";
- } else if (parallelepipedVolume(a, b, c) < parallelepipedVolume(a1, b1, c1) && isBiggerBox(a1, b1, c1, a, b, c)) {
- return "The first box is smaller than the second one";
- }
- return "Boxes are incomparable";
- }
- console.log(comparison(1, 2, 3, 3, 2, 1));
- console.log(comparison(2, 2, 3, 3, 2, 1));
- console.log(comparison(2, 2, 3, 3, 2, 3));
- console.log(comparison(3, 4, 5, 2, 4, 6));
- console.info(comparison(1, 1, 1, 2, 2, 2));
- console.info(comparison(1, 7, 1, 2, 2, 2));
- console.info(comparison(1, 2, 1, 2, 1, 2));
Add Comment
Please, Sign In to add comment