Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function partyTime(input) {
- let indexOfParty = input.indexOf('PARTY');
- let vipList = [];
- let normalList = [];
- for (let i = 0; i < indexOfParty; i++) {
- let word = input[i];
- if (isNaN(word[0])) {
- normalList.push(input[i]);
- }
- else {
- vipList.push(input[i]);
- }
- }
- for (let i = indexOfParty + 1; i < input.length; i++) {
- if (vipList.includes(input[i])) {
- let index = vipList.indexOf(input[i]);
- vipList.splice(index, 1);
- }
- if (normalList.includes(input[i])) {
- let index = normalList.indexOf(input[i]);
- normalList.splice(index, 1);
- }
- }
- console.log(vipList.length + normalList.length);
- for (let name of vipList) {
- console.log(name);
- }
- for (let name of normalList) {
- console.log(name);
- }
- }
- //let reader = process.openStdin();
- //partyTime(['dublikat',
- // 'dublikat',
- // 'dublikat',
- // '9CQBGUeJ',
- // 'PARTY',
- // 'dublikat',
- // '9CQBGUeJ']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement