Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function task( arr){
  2.  
  3.     let maxQuantity= Number(arr[0]);
  4.     let days = Number(arr[1]);
  5.  
  6.     let costs=0;
  7.     let spirit =0;
  8.  
  9.     for (let index = 1; index <= days; index++) {
  10.    
  11.         if (index%11==0){
  12.             maxQuantity+=2;
  13.         }
  14.         if (index%2==0){
  15.             costs+= maxQuantity*2;
  16.             spirit+=5;
  17.         }
  18.         if ( index%3==0){
  19.             costs+= (3+5)*maxQuantity;
  20.             spirit+=13
  21.         }
  22.         if(index%5==0){
  23.             costs+=15*maxQuantity;
  24.             spirit+=17;
  25.             if(index%3==0){
  26.                 spirit +=30;
  27.             }
  28.  
  29.         }
  30.         if (index%10==0){
  31.             spirit-=20;
  32.             costs+= 15+5+3;
  33.             if (days==10){
  34.                 spirit-=30;
  35.             }
  36.         }
  37.        
  38.     }
  39.     console.log(`Total cost: ${costs}`);
  40.     console.log(`Total spirit: ${spirit}`);
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement