Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import Counter
- p = (
- ('z', 'zero', 0),
- ('w', 'two', 2),
- ('g', 'eight', 8),
- ('t', 'three', 3),
- ('r', 'four', 4),
- ('x', 'six', 6),
- ('s', 'seven', 7),
- ('o', 'one', 1),
- ('v', 'five', 5),
- ('i', 'nine', 9),
- )
- def func(s):
- c = Counter(s)
- for char, word, num in p:
- n = c.get(char, 0)
- if n == 0:continue
- tmp = Counter(word)
- for i in range(n):
- c -= tmp
- yield n
- class Solution:
- def originalDigits(self, s: str) -> str:
- return "".join(map(str, sorted(list(func(s)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement