Created
May 21, 2014 17:43
-
-
Save yanatan16/3a732315245d6a0d4379 to your computer and use it in GitHub Desktop.
Calculate the number of ability combinations from function usage in Transistor. (answer: 22 billion)
This file contains 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
#!/usr/bin/env python3 | |
from math import factorial | |
def combinations(n): | |
''' Given n functions to be selected, return how many combinations for selecting those functions there are ''' | |
return int(factorial(16) / factorial(16-n)) | |
def get_all_combinations(): | |
''' | |
- Calculate all possible unique combinations of number of functions in each slot of actives and passives | |
- We enforce that no active slot (a,b,c,d) will have more functions than the slot before to eliminate | |
having duplicates like (1,2,1,0) and (2,1,1,0) | |
''' | |
return [(a,b,c,d,p) for a in range(0,3+1) # First active can take any number of functions 0 to 3 | |
for b in range(0,a+1) # Second active can take any number of functions 0 to a | |
for c in range(0,b+1) # etc | |
for d in range(0,c+1) | |
for p in range(0,2+1)] # Passives can range from 0 to 2 always | |
def calculate(): | |
actives = get_all_combinations() | |
print(actives) | |
combs = [combinations(sum(act)) for act in actives] | |
print('Total combinations: %d from %d slot arrangements' % (sum(combs), len(combs))) | |
if __name__ == '__main__': | |
calculate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment