Advertisement
Grossos

Renovation

Jun 27th, 2023 (edited)
1,025
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function renovation(input) {
  2.  
  3.  
  4.     let height = Number(input[0]);
  5.     let width = Number(input[1]);
  6.     let percent = Number(input[2]);
  7.     let percentFix = (100 - percent) / 100;
  8.  
  9.     let quadratic = height * width * 4;
  10.  
  11.     let paintableArea = Math.ceil(quadratic * percentFix);
  12.  
  13.     let index = 3;
  14.     let command = input[index];
  15.  
  16.     let sumPaint = 0;
  17.  
  18.     while (command !== 'Tired!') {
  19.  
  20.         let paint = Number(command);
  21.         sumPaint += paint;
  22.  
  23.         index++;
  24.         command = input[index];
  25.  
  26.     }
  27.  
  28.     let total = paintableArea - sumPaint;
  29.  
  30.  
  31.     if (total === 0) {
  32.         console.log(`All walls are painted! Great job, Pesho!`);
  33.  
  34.     } else if (total > 0) {
  35.         console.log(`${paintableArea - sumPaint} quadratic m left.`);
  36.  
  37.     } else {
  38.         console.log(`All walls are painted and you have ${Math.abs(total)} l
  39.     paint left!`);
  40.  
  41.     }
  42. }
  43. renovation(["2",
  44.     "3",
  45.     "25",
  46.     "6",
  47.     "7",
  48.     "8"])
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement