Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Cinema(input){
- let vaucher = Number(input.shift());
- let price = 0;
- let buyProduct = 0;
- let buyTicket = 0;
- let command = input.shift();
- while(command !== 'End'){
- if(command.length > 8){
- price = command.charCodeAt(0) + command.charCodeAt(1);
- if(price <= vaucher ){
- buyTicket++;
- vaucher -= price;
- }
- else{
- break;
- }
- }
- if(command.length <= 8){
- price = command.charCodeAt(0);
- if(price <= vaucher){
- buyProduct++;
- vaucher -= price;
- }else{
- break;
- }
- }
- command = input.shift();
- }
- console.log(buyTicket);
- console.log(buyProduct);
- }
Advertisement
Add Comment
Please, Sign In to add comment