didkoslawow

Untitled

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