Created
June 9, 2011 04:19
-
-
Save lxneng/1016051 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import random | |
>>> ''.join(random.sample('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', 4)) | |
'eKq1' | |
>>> # 62!/(62-4)! = 13 388 280 | |
>>> # (62 !) / ((62 - 3) !) = 226 920 | |
>>> # (62 !) / ((62 - 4) !) = 13 388 280 | |
>>> def factorial(n): | |
... return reduce(lambda x,y: x*y, range(1,n+1)) | |
... | |
... | |
>>> def p(m,n): | |
... """m!/(m-n)!""" | |
... return factorial(m)/factorial(m-n) | |
... | |
... | |
>>> p(62,4) | |
13388280L | |
>>> p(62,3) | |
226920L |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment