Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import Counter
- _temp = raw_input("Please enter a string: ")
- def permutate_count(perm):
- rank = 1
- perma = 1
- count = Counter()
- for i in range(len(perm)):
- x = perm[((len(perm) - 1) - i)]
- print x
- count[x] += 1
- for j in count:
- if (j < x):
- rank += ((perma * count[j]) // count[x])
- perma = ((perma * (i + 1)) // count[x])
- return rank, perma
- print permutate_count(_temp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement