Skip to content

Commit

Permalink
Add kattis prob anagramcounting in Python2
Browse files Browse the repository at this point in the history
  • Loading branch information
iandioch committed Dec 21, 2016
1 parent bb1cc07 commit deb90c1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions kattis/anagramcounting/solution.py
@@ -0,0 +1,19 @@
import sys

def fact(n):
ans = 1;
for i in xrange(2, n+1):
ans *= i
return ans

for line in sys.stdin.readlines():
letter_counts = {}
for letter in line[:-1]:
if letter in letter_counts:
letter_counts[letter] += 1
else:
letter_counts[letter] = 1
ans = fact(len(line)-1)
for letter in letter_counts:
ans /= fact(letter_counts[letter])
print(ans)

0 comments on commit deb90c1

Please sign in to comment.