Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(listOfGuests) {
- let VIP = [];
- let regular = []; // 'regular' :(
- while (true) {
- if (listOfGuests[0] === "PARTY") {
- listOfGuests.shift();
- break;
- }
- let guest = listOfGuests[0];
- if (!isNaN(parseInt(guest[0], 10))) {
- VIP.push(guest);
- } else {
- regular.push(guest);
- }
- listOfGuests.shift();
- }
- for (let i = 0; i < listOfGuests.length; i++) {
- let guest = listOfGuests[i];
- if (!isNaN(parseInt(guest[0], 10))) {
- let index = VIP.indexOf(guest);
- VIP.splice(index, 1);
- }else{
- let index = regular.indexOf(guest);
- regular.splice(index, 1);
- }
- }
- let missingGuests = VIP.concat(regular);
- console.log(missingGuests.length);
- for (const missingGuest of missingGuests) {
- console.log(missingGuest);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment