didkoslawow

Untitled

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