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 treatenPatients = 0;
- let totalTreated = 0;
- let untreatenPatients = 0;
- for (let i = 1; i < period; i++) {
- patientsDaylyCounter = Number(input[i]);
- if (i % 3 === 0) {
- if (untreatenPatients > treatenPatients) {
- doctors++;
- }
- }
- if (patientsDaylyCounter > doctors) {
- untreatenPatients += patientsDaylyCounter - doctors;
- treatenPatients += patientsDaylyCounter - untreatenPatients;
- } else {
- treatenPatients += doctors;
- }
- }
- console.log(`Treated patients: ${treatenPatients}.`);
- console.log(`Untreated patients: ${untreatenPatients}.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment