Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- РЕШЕНИЕ С РЕЧНИК И SHIFT() ЛЕКО ТАРИКАТСКАТА:
- function cinemaTickets(input) {
- let tickets = {kid: 0, student: 0, standard: 0};
- while (input[0] !== 'Finish') {
- let movie = input.shift();
- let volume = Number(input.shift());
- let soldTicket = 0;
- while (input[0] !== 'End' && soldTicket !== volume) {
- tickets[input.shift()]++;
- soldTicket++;
- }
- console.log(`${movie} - ${((soldTicket / volume) * 100).toFixed(2)}% full.`);
- if (soldTicket !== volume) {
- input.shift();
- }
- }
- let totalTicket = tickets.kid + tickets.student + tickets.standard;
- console.log(`Total tickets: ${totalTicket}`);
- console.log(`${((tickets.student / totalTicket) * 100).toFixed(2)}% student tickets.`);
- console.log(`${((tickets.standard / totalTicket) * 100).toFixed(2)}% standard tickets.`);
- console.log(`${((tickets.kid / totalTicket) * 100).toFixed(2)}% kids tickets.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement