Advertisement
Guest User

Untitled

a guest
Apr 20th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. from collections import Counter
  2. _temp = raw_input("Please enter a string: ")
  3.  
  4.  
  5. def permutate_count(perm):
  6.     rank = 1
  7.     perma = 1
  8.     count = Counter()
  9.     for i in range(len(perm)):
  10.         x = perm[((len(perm) - 1) - i)]
  11.         print x
  12.         count[x] += 1
  13.         for j in count:
  14.             if (j < x):
  15.                 rank += ((perma * count[j]) // count[x])
  16.         perma = ((perma * (i + 1)) // count[x])
  17.     return rank, perma
  18. print permutate_count(_temp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement