Advertisement
Guest User

suitcasesLoaded

a guest
Apr 2nd, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input){
  2.     let planeCapacity = Number(input.shift());
  3.  
  4.     let suitcasesCount = 0;
  5.  
  6.     while (true){
  7.         let suitcase = input.shift();
  8.  
  9.         if (suitcase === `End`){
  10.             console.log(`Congratulations! All suitcases are loaded!`)
  11.             break;
  12.         }
  13.         if (suitcasesCount % 3 == 0){
  14.             planeCapacity -= suitcase * 1.1
  15.         }
  16.         else{
  17.             planeCapacity -= suitcase
  18.         }      
  19.         if (planeCapacity < 0){
  20.             console.log(`No more space!`)
  21.             break;
  22.         }
  23.         suitcasesCount += 1;
  24.     }
  25.     console.log(`Statistic: ${suitcasesCount} suitcases loaded.`)
  26. }
  27. // solve(["550", "100", "252", " 72", "End"]);
  28. // solve(["700.5", "180", "340.6", " 126", "220"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement