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