# Find the gatecrashers on CocoBongo parties

CocoBongo is a club with very nice parties. However, you only can get inside if you know at least one other guest. Unfortunately, some gatecrashers can appear at those parties. The gatecrashers do not know any other party member and should not be at our amazing party!

We will give to you a collection with all party members and a collection with some guests and their invitations. Your mission is to find out those gatecrashers and give us a sorted array of them.

Note that invitations are undirectional relations, so if guest `A` invites `B`, we can consider that `B` also knows `A`. Once the relation `(A, {B})` appears on the invitations collection, the reverse relation `(B, {A})` may or may not appear in the input. You need to take care of that.

## Example

```python
party_members = [0,1,2,3,4]
invitations = [ (0, [1,2]), (2, [3]) ]
gatecrashers = [4]
```

## Explanation

We have `invitations = [ (0, [1,2]), (2, [3]) ]`.  
Guest `0` has invited guests `1` and `2`; also, guest `2` has invited guest `3`.
However, noone has invited guest `4`, so he is a gatecrasher.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Graph algorithms

Data structures

Starter code: def find_gatecrashers(people, invitations):
	

Solutions:
def find_gatecrashers(people, invitations):
	crashersSet = {elt for (i, li) in invitations for elt in [i] + li}
	return [p for p in people if p not in crashersSet]


find_gatecrashers = lambda p, i: sorted(set(p) - {elt for (j, lst) in i for elt in lst + [j]})


def find_gatecrashers(people, invitations):
	ok = set()
	for i in invitations:
		(a, b) = i
		ok.add(a)
		for ii in b:
			ok.add(ii)
	return sorted(list(set(people) - ok))


def find_gatecrashers(ps, ivs):
	return sorted(set(ps) - set((e for p in ivs for e in [p[0]] + p[1])))


def find_gatecrashers(people, invitations):
	guests = []
	for (guest, otherGuests) in invitations:
		guests.append(guest)
		guests.extend(otherGuests)
	return sorted(set(people).difference(set(guests)))


find_gatecrashers = lambda p, i: (lambda c: [q for q in p if q not in c])({e for (j, l) in i for e in [j] + l})


import random
random.randint = lambda *args: 1

def find_gatecrashers(people, invitations):
	inv = set()
	for (a, bs) in invitations:
		inv.add(a)
		inv.update(bs)
	return [p for p in people if p not in inv]


def find_gatecrashers(people, invitations):
	legit_people = []
	combo_breakers = []
	for ell in invitations:
		for ell2 in ell:
			if isinstance(ell2, int):
				legit_people.append(ell2)
			elif isinstance(ell2, list):
				for ell3 in ell2:
					legit_people.append(ell3)
	legit_people = set(legit_people)
	for ell4 in people:
		if ell4 not in legit_people:
			combo_breakers.append(ell4)
	return sorted(list(combo_breakers))


def find_gatecrashers(people, invitations):
	inv_set = set()
	for i in invitations:
		inv_set.add(i[0])
		inv_set.update(i[1])
	res = sorted(list(set(people) - inv_set))
	return res


def find_gatecrashers(people, invitations):
	known = set()
	for (inviting, invited) in invitations:
		known.add(inviting)
		known |= set(invited)
	return [p for p in people if p not in known]