SHARE
TWEET

PartyTime

a guest Mar 8th, 2020 175 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function partyTime(input) {
  2.     let vipGuestsList = [];
  3.     let regularGuestsList = [];
  4.     let reservation = input.shift();
  5.     while (reservation !== 'PARTY') {
  6.         if (/^\d+/.test(reservation)) {
  7.             vipGuestsList.push(reservation);
  8.         } else {
  9.             regularGuestsList.push(reservation);
  10.         }
  11.         reservation = input.shift();
  12.     }
  13.     for (let guest of input) {
  14.         if (vipGuestsList.indexOf(guest) >= 0) {
  15.             vipGuestsList.splice(vipGuestsList.indexOf(guest), 1);
  16.         }
  17.         if (regularGuestsList.indexOf(guest) >= 0) {
  18.             regularGuestsList.splice(regularGuestsList.indexOf(guest), 1);
  19.         }
  20.     }
  21.     console.log(vipGuestsList.length + regularGuestsList.length);
  22.     vipGuestsList.forEach(el => console.log(el));
  23.     regularGuestsList.forEach(el => console.log(el));
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top