DimiPetrov

PB - Renovation

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