Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(arr) {
- let vips = [];
- let regular = [];
- for (const guest of arr.splice(0, arr.indexOf('PARTY'))) {
- (!isNaN(guest[0])) ? vips.push(guest): regular.push(guest);
- }
- for (let incomingGuest of arr.splice(1,)) {
- if (!isNaN(incomingGuest[0]) && vips.includes(incomingGuest)) {
- vips.splice(vips.indexOf(incomingGuest), 1);
- } else if (regular.includes(incomingGuest)) {
- regular.splice(regular.indexOf(incomingGuest), 1);
- }
- }
- console.log(vips.length + regular.length);
- if (vips.length > 0) { console.log(vips.join('\n')); }
- if (regular.length > 0) { console.log(regular.join('\n')); }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement