Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function renovation (input) {
- let index = 0;
- let h = Number(input[index]);
- index++;
- let w = Number(input[index]);
- index++;
- let percNotColoring = Number(input[index]);
- index++;
- let command = input[index];
- let sizes = h * w * 4;
- let wallsForPainting = sizes - (sizes * percNotColoring) / 100;
- let paintLeft = 0;
- while (command !== "Tired!") {
- let paintLs = Number(input[index]);
- if (wallsForPainting <= paintLs) {
- paintLeft = paintLs - wallsForPainting;
- if (wallsForPainting < paintLs) {
- console.log(`All walls are painted and you have ${paintLeft} l paint left!`);
- break;
- } else {
- console.log("All walls are painted! Great job, Pesho!");
- break;
- }
- }
- wallsForPainting -= paintLs;
- index++;
- command = input[index];
- }
- if (command === "Tired!") {
- console.log(`${wallsForPainting} quadratic m left.`)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement