Since the groups of 6 represent dice, the order of the integers in these groups does not matter. The order of the groups within each set does matter, but to check each one it would be simple to find the permutations of each set, which I can do.
Now, I've come up with a way to achieve all this, the problem is efficiency. I want to check each set but so far I've only come up with a way using:
for i in itertools.combinations(num, 6):
W.append([i])
print(W)
print("Done building list of ",len(W)," possible dice.")
which gives me all possible dice of 6 numbers chosen from 18 integers where the order of the numbers doesn't matter. This is 18,564 groups of 6. Then, I find the combination of these dice using:
for j in itertools.combinations(W, 3):
check = list(itertools.chain(*list(itertools.chain(*j))))
check = sorted(check)
#print(check)
if check == num:
The issue arises from the fact that the second combination will iterate through 10^15 possibilities where only a small fraction of that is what I want to generate.
Another question I have:
I'm pretty sure that the total ways to assign 18 things to 3 distinct groups of 6 where the order within the groups doesn't matter is given by: 18!/(6!)^3 ~ 17 million ways, which can be iterated through relatively quickly. Is this right? Is there a way to generate these ways iteratively without filtering through a much larger set of possibilities?
One last note:
What I'm doing is trying to generate all sets of non-transitive six sided dice where each face of each dice has a distinct number. I already have the code that can check a set and decide if it fits this condition and store the best result, i.e. the highest probability of a dice beating the next dice in the line.
for k in itertools.permutations(j):
B = k[0]
G = k[1]
R = k[2]
b = 0
g = 0
r = 0
for m in B:
for n in G:
if m > n:
b = b + 1
else:
continue
for m in G:
for n in R:
if m > n:
g = g + 1
else:
continue
for m in R:
for n in B:
if m > n:
r = r + 1
else:
continue
w = w + 1
print(w)
if b <= 18 or g <= 18 or r <= 18:
continue
else:
if b >= blue and g >= green and r >= red:
Blue = B
blue = b
Green = G
green = g
Red = R
red = r
print(B)
print(b/36)
print(G)
print(g/36)
print(R)
print(r/36)
continue
else:
continue
else:
continue