Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let seats = Number(input[0]);
- let people = 0;
- let income = 0;
- let index = 1;
- let command = input[index];
- index++;
- while(command !== 'Movie time!' && people + command <= seats) {
- people += command;
- if(command % 3 === 0) {
- income += command * 5 - 5;
- } else {
- income += command * 5;
- }
- command = input[index];
- index++;
- }
- if(people > seats) {
- console.log(`The cinema is full.`);
- console.log(`Cinema income - ${income} lv.`);
- } else {
- console.log(`There are ${seats - people} seats left in the cinema.`);
- console.log(`Cinema income - ${income} lv.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement