Advertisement
viking_unet

Untitled

Apr 23rd, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. s = input().split('\n')
  2.  
  3. elements = dict([tuple(x.split(': ')) for x in s])
  4. last_kinds = set()
  5. out_str = ''
  6. for drug, kind in elements.items():
  7. if kind in last_kinds:
  8. continue
  9. same_kind_drugs = ' # '.join(sorted([x for x, y in elements.items() if y == kind]))
  10. row_str = '%s - %s' % (kind, same_kind_drugs)
  11. last_kinds.add(kind)
  12. if out_str:
  13. out_str += '\n'
  14. out_str += row_str
  15. print(out_str)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement