didkoslawow

Untitled

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