Advertisement
simeonshopov

Party Time

Apr 14th, 2021
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr) {
  2.   let vips = [];
  3.   let regular = [];
  4.  
  5.   for (const guest of arr.splice(0, arr.indexOf('PARTY'))) {
  6.     (!isNaN(guest[0])) ? vips.push(guest): regular.push(guest);
  7.   }
  8.  
  9.   for (let incomingGuest of arr.splice(1,)) {
  10.     if (!isNaN(incomingGuest[0]) && vips.includes(incomingGuest)) {
  11.       vips.splice(vips.indexOf(incomingGuest), 1);
  12.     } else if (regular.includes(incomingGuest)) {
  13.       regular.splice(regular.indexOf(incomingGuest), 1);
  14.     }
  15.   }
  16.  
  17.   console.log(vips.length + regular.length);
  18.   if (vips.length > 0) { console.log(vips.join('\n')); }
  19.   if (regular.length > 0) { console.log(regular.join('\n')); }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement