Advertisement
Spocoman

02. Sleepy Tom Cat

Dec 18th, 2021 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sleepyTomCat(input) {
  2.     let day = parseInt(input[0]);
  3.     let work = (365 - day) * 63;
  4.     let holiday = day * 127;
  5.     let sum = work + holiday;
  6.     let minutes = 0;
  7.  
  8.     if (sum >= 30000) {
  9.         minutes = sum - 30000;
  10.         console.log("Tom will run away");
  11.         if (minutes % 60 < 10) {
  12.             console.log(`${Math.floor(minutes/60)} hours and 0${minutes % 60} minutes more for play`);
  13.         } else {
  14.             console.log(`${Math.floor(minutes/60)} hours and ${minutes % 60} minutes more for play`);
  15.         }
  16.     } else {
  17.         minutes = 30000 - sum;
  18.         console.log("Tom sleeps well");
  19.         if (minutes % 60 < 10 && minutes == 0) {
  20.             console.log(`${Math.floor(minutes/60)} hours and 0${minutes % 60} minutes less for play`);
  21.         } else {
  22.             console.log(`${Math.floor(minutes/60)} hours and ${minutes % 60} minutes less for play`);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement