Advertisement
LilChicha174

Untitled

Dec 24th, 2021
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. def solve(values):
  2.     a = list(values.split(';'))
  3.     b = []
  4.     for i in range(1, int(a[0]) + 1):
  5.         b.append(a[i])
  6.    
  7.     c = []
  8.     for i in range(int(a[0]) + 2, len(a)):
  9.         c.append(a[i])
  10.    
  11.     d = {}
  12.     for i in b:
  13.         if ':' in i:
  14.             son, dad = i.split(":")
  15.             son = son.replace(' ', '')
  16.             dad = dad.replace(' ', '')
  17.             d[dad] = son
  18.    
  19.     s = []
  20.     for i in range(len(c)):
  21.         for j in range(i + 1):
  22.             if c[j] in list(d.keys()):
  23.                 if d[c[j]] == c[i]:
  24.                     s.append(c[i])
  25.        
  26.     return ','.join(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement