Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function renovation(input) {
- let height = Number(input[0]);
- let width = Number(input[1]);
- let percent = Number(input[2]);
- let percentFix = (100 - percent) / 100;
- let quadratic = height * width * 4;
- let paintableArea = Math.ceil(quadratic * percentFix);
- let index = 3;
- let command = input[index];
- let sumPaint = 0;
- while (command !== 'Tired!') {
- let paint = Number(command);
- sumPaint += paint;
- index++;
- command = input[index];
- }
- let total = paintableArea - sumPaint;
- if (total === 0) {
- console.log(`All walls are painted! Great job, Pesho!`);
- } else if (total > 0) {
- console.log(`${paintableArea - sumPaint} quadratic m left.`);
- } else {
- console.log(`All walls are painted and you have ${Math.abs(total)} l
- paint left!`);
- }
- }
- renovation(["2",
- "3",
- "25",
- "6",
- "7",
- "8"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement