Advertisement
Liliana797979

viarno reshenie renovation

Feb 3rd, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.      
  2. function solve(input) {
  3.   let h = Number(input.shift());
  4.   let w = Number(input.shift());
  5.   let nonPaintArea = Number(input.shift());
  6.   let walls = (h * w * 4) * (100 - nonPaintArea) / 100;
  7.   let paintedWalls = 0;
  8.   let command = input.shift();
  9.  
  10.   while(command !== 'Tired!') {
  11.     let paint = Number(command);
  12.     paintedWalls += paint;
  13.     if(paintedWalls >= walls) {
  14.       break;
  15.     }
  16.     command = input.shift();
  17.   }
  18.  
  19.   if(command === 'Tired!') {
  20.     console.log(`${Math.ceil(walls - paintedWalls)} quadratic m left.`);
  21.   } else if(paintedWalls > walls) {
  22.     console.log(`All walls are painted and you have ${Math.ceil(paintedWalls - walls)} l paint left!`);
  23.   } else if(paintedWalls === walls) {
  24.     console.log(`All walls are painted! Great job, Pesho!`);
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement