Advertisement
Spocoman

Happy Cat Parking

Jan 9th, 2022
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function happyCatParking(input) {
  2.  
  3.     let days = Number(input[0]);
  4.     let hours = Number(input[1]);
  5.  
  6.     let total = 0;
  7.  
  8.     for (let day = 1; day <= days; day++) {
  9.         let sum = 0;
  10.  
  11.         for (let hour = 1; hour <= hours; hour++) {
  12.             if (day % 2 === 0 && hour % 2 === 1) {
  13.                 sum += 2.50;
  14.             } else if (day % 2 === 1 && hour % 2 === 0) {
  15.                 sum += 1.25;
  16.             } else {
  17.                 sum++;
  18.             }
  19.         }
  20.         console.log(`Day: ${day} - ${sum.toFixed(2)} leva`);
  21.         total += sum;
  22.     }
  23.     console.log(`Total: ${total.toFixed(2)} leva`);
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement