Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- from collections import Counter
- #permutations
- print(list(map("".join, itertools.permutations('hello'))))
- #n most common elements in arr and num occurences
- arr = [1, 3, 4, 1, 2, 1, 1, 3, 4, 3, 5, 1, 2, 5, 3, 4, 5]
- counter = Counter(arr)
- top_three = counter.most_common(3)
- #string at [::-1] is reverse
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement