-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdifferent_combinations.py
More file actions
126 lines (83 loc) · 3.23 KB
/
different_combinations.py
File metadata and controls
126 lines (83 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import math
import copy
class DifferentCombinations(object):
"""Calculates possible combinations for items, runes, masteries, champions.
"""
ITEM_SLOTS = 6
RED_SLOTS = 9
YELLOW_SLOTS = 9
BLUE_SLOTS = 9
QUINT_SLOTS = 3
def __init__(self,
different_items,
different_red,
different_yellow,
different_blue,
different_quint,
champions,
):
self.different_items = different_items
self.different_red = different_red
self.different_yellow = different_yellow
self.different_blue = different_blue
self.different_quint = different_quint
self.champions = champions
@staticmethod
def ordered_combinations(n, k):
"""Returns total combinations if there are n different elements and k choices,
when element order is irrelevant.
"""
return math.factorial(n) / (math.factorial(k) * math.factorial(n-k))
def item_combinations(self):
return self.ordered_combinations(n=self.different_items, k=self.ITEM_SLOTS)
def total_rune_combinations(self):
k_name = lambda color: getattr(self, color.upper() + '_SLOTS')
n_name = lambda color: getattr(self, 'different_' + color)
combinations = lambda color: self.ordered_combinations(n=n_name(color), k=k_name(color))
tot_combs = 1
for color_name in ('red', 'blue', 'yellow', 'quint'):
tot_combs *= combinations(color_name)
return tot_combs
def total_combinations(self):
return self.total_rune_combinations() * self.item_combinations() * self.champions
def __repr__(self):
msg = '\nitem combinations: %s' % '{:.2e}'.format(self.item_combinations())
msg += '\nrune combinations: %s' % '{:.2e}'.format(self.total_rune_combinations())
msg += '\nTOTAL COMBINATIONS: %s' % '{:.2e}'.format(self.total_combinations())
return msg
class NormalCombinations(object):
SETUP_PARAMETERS = dict(
# ITEMS
different_items=273,
# RUNES
different_red=12,
different_yellow=12,
different_blue=12,
different_quint=12,
# CHAMPIONS
champions=119,)
def instance(self):
return DifferentCombinations(**self.SETUP_PARAMETERS)
def __repr__(self):
msg = '\n-----------------------------'
msg += '\nNORMAL COMBINATIONS'
msg += self.instance().__repr__()
return msg
class ManalessCombinations(object):
SETUP_PARAMETERS = copy.deepcopy(NormalCombinations.SETUP_PARAMETERS)
SETUP_PARAMETERS['champions'] -= 19
SETUP_PARAMETERS['different_items'] -= 2
SETUP_PARAMETERS['different_red'] -= 2
SETUP_PARAMETERS['different_yellow'] -= 2
SETUP_PARAMETERS['different_blue'] -= 2
SETUP_PARAMETERS['different_quint'] -= 2
def instance(self):
return DifferentCombinations(**self.SETUP_PARAMETERS)
def __repr__(self):
msg = '\n-----------------------------'
msg += '\nMANALESS COMBINATIONS'
msg += self.instance().__repr__()
return msg
if __name__ == '__main__':
print(NormalCombinations())
print(ManalessCombinations())