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