Advertisement
GalinaKG

Untitled

May 6th, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. function renovation (input) {
  2. let index = 0;
  3. let h = Number(input[index]);
  4. index++;
  5. let w = Number(input[index]);
  6. index++;
  7. let percNotColoring = Number(input[index]);
  8. index++;
  9. let command = input[index];
  10. let sizes = h * w * 4;
  11. let wallsForPainting = sizes - (sizes * percNotColoring) / 100;
  12. let paintLeft = 0;
  13.  
  14. while (command !== "Tired!") {
  15. let paintLs = Number(input[index]);
  16.  
  17. if (wallsForPainting <= paintLs) {
  18. paintLeft = paintLs - wallsForPainting;
  19. if (wallsForPainting < paintLs) {
  20. console.log(`All walls are painted and you have ${paintLeft} l paint left!`);
  21. break;
  22. } else {
  23. console.log("All walls are painted! Great job, Pesho!");
  24. break;
  25. }
  26. }
  27.  
  28. wallsForPainting -= paintLs;
  29.  
  30. index++;
  31. command = input[index];
  32. }
  33. if (command === "Tired!") {
  34. console.log(`${wallsForPainting} quadratic m left.`)
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement