xml_mdf.py 382 B

123456789101112131415161718192021
  1. '''
  2. > https://www.codingame.com/ide/puzzle/xml-mdf-2016
  3. @author: olivier.massot, 2019
  4. '''
  5. s = "ab-bcd-d-c-ae-e"
  6. opened, depth, score = True, 0, {}
  7. for c in s:
  8. if c == '-':
  9. opened = False
  10. elif opened:
  11. depth += 1
  12. else:
  13. score[c] = score.get(c, 0) + 1 / depth
  14. depth -= 1
  15. opened = True
  16. print(score)
  17. print(max(score, key=score.get))