Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hospital(input) {
- let period = Number(input[0]);
- let doctors = 7;
- let day3check = 1;
- let treatenPatients = 0;
- let untreatenPatients = 0;
- for (let i = 1; i < input.length; i++) {
- i = Number(input[i]);
- if (i <= doctors) {
- treatenPatients += doctors;
- } else {
- untreatenPatients += i - doctors;
- }
- if (day3check % 3 === 0) {
- if (untreatenPatients > treatenPatients) {
- doctors++;
- }
- }
- day3check++;
- }
- console.log(`Treated patients: ${treatenPatients}`);
- console.log(`Untreated patients: ${untreatenPatients}`);
- }
- hospital(["4", "7", "27", "9", "1"]);
Advertisement
Add Comment
Please, Sign In to add comment