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