Advertisement
desislava_topuzakova

02. Hospital

Jul 28th, 2024
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. function hospital (input) {
  2. let days = Number(input[0]);
  3.  
  4. let doctors = 7;
  5. let examinedPatients = 0;
  6. let unexaminedPatients = 0;
  7.  
  8. for (let day = 1; day <= days; day++) {
  9. let dayPacients = Number(input[day]);
  10.  
  11. if (day % 3 === 0) {
  12. if (examinedPatients < unexaminedPatients) {
  13. doctors++;
  14. }
  15. }
  16.  
  17. if (dayPacients > doctors) {
  18. examinedPatients += doctors;
  19. unexaminedPatients += dayPacients - doctors;
  20. } else {
  21. examinedPatients += dayPacients;
  22. }
  23. }
  24. console.log(`Treated patients: ${examinedPatients}.`);
  25. console.log(`Untreated patients: ${unexaminedPatients}.`);
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement