Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let guests = {
- vip: [],
- regular: []
- };
- let inParty = false;
- for (let i = 0; i < input.length; i++) {
- let current = input[i];
- if (current === "PARTY") {
- inParty = true;
- continue;
- }
- if (!inParty) {
- if (isNaN(current[0])) {
- guests.regular.push(current);
- } else {
- guests.vip.push(current);
- }
- } else {
- if (isNaN(current[0])) {
- if (guests.regular.includes(current)) {
- guests.regular.splice(guests.regular.indexOf(current), 1);
- }
- } else {
- if (guests.vip.includes(current)) {
- guests.vip.splice(guests.vip.indexOf(current), 1);
- }
- }
- }
- }
- let remainingGuestsCount = guests.vip.length + guests.regular.length;
- console.log(remainingGuestsCount);
- console.log(guests.vip.join('\n'));
- console.log(guests.regular.join('\n'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement