Advertisement
Marin171

Moving

Sep 7th, 2022
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. function solve(input) {
  2. let width = Number(input.shift());
  3. let length = Number(input.shift());
  4. let heigth = Number(input.shift());
  5. let volume = width * length * heigth;
  6. let movedCartons = 0;
  7.  
  8. while(true) {
  9. numCartons = input.shift();
  10. if(Number(numCartons) || numCartons == "undefined" || numCartons == "Done") {
  11. break;
  12. } else {
  13. movedCartons += numCartons;
  14. }
  15. }
  16. if(movedCartons > volume) {
  17. console.log(`No more free space! You need ${Math.abs(movedCartons - volume)} Cubic meters more.`);
  18. } else {
  19. console.log(`${Math.abs(movedCartons - volume)} Cubic meters left.`);
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement