Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solve(values):
- a = list(values.split(';'))
- b = []
- for i in range(1, int(a[0]) + 1):
- b.append(a[i])
- c = []
- for i in range(int(a[0]) + 2, len(a)):
- c.append(a[i])
- d = {}
- for i in b:
- if ':' in i:
- son, dad = i.split(":")
- son = son.replace(' ', '')
- dad = dad.replace(' ', '')
- d[dad] = son
- s = []
- for i in range(len(c)):
- for j in range(i + 1):
- if c[j] in list(d.keys()):
- if d[c[j]] == c[i]:
- s.append(c[i])
- return ','.join(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement