Skip to content

Instantly share code, notes, and snippets.

@tjt263
Created March 27, 2019 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjt263/a15250625cd77c35b71b8f85b350ca1f to your computer and use it in GitHub Desktop.
Save tjt263/a15250625cd77c35b71b8f85b350ca1f to your computer and use it in GitHub Desktop.
permutations of a set
#!/usr/bin/env python3
import string
import time
print('\033c')
x = string.ascii_uppercase
for a in x:
for b in x:
for c in x:
for d in x:
print(a,b,c,d,end='\r')
time.sleep(0.01)
print('\033c')
@tjt263
Copy link
Author

tjt263 commented Mar 27, 2019

#!/usr/bin/env python3

from math import factorial

#   P ( n , r )
# ( P ( n , r ) = n ! / ( n - r ) ! )

def P ( n , r ):
    return int ( factorial ( n ) / factorial ( ( n - r ) ) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment