simeonshopov

Party Time

Apr 14th, 2021
315
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. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×