Imagine five colors on a wheelwhite, blue, black, red, and green, looping back to white. I have 20 cards with some of those colors on each. 5 have four of the colors, each missing a different one. 5 have two colors; 1 of each possible combination of colors next to each other on the wheel (whiteblue, blueblack, etc.) 10 have two colors that are not next to each other; 2 distinct cards for each possible color combination. How many ways can I make 5 piles of cards where each pile has exactly four colors, each pile is missing a different color, and each pile consists of either 1 fourcolor card, or 2 twocolor cards?
Some of you may recognize that what I'm really asking is "If I have one of each of the 2016 MTG Commander decks, how many ways can I swap around the commanders for all five decks?"
Combinatoric commanders
Moderators: gmalivuk, Moderators General, Prelates

 Posts: 35
 Joined: Fri Feb 05, 2016 3:39 pm UTC
Re: Combinatoric commanders
I tried to do it by listing the possible cases, but it's really complicated. I'd try a program, but I'm not that good of a programmer.
It looks like the answer is somewhere around 20000, however.
It looks like the answer is somewhere around 20000, however.
Re: Combinatoric commanders
I'll represent the colors by their initials, except I'll use the printers' convention of using K for black, so our colors in colorwheel order are WBKRG.
The 5 fourcolor cards are
BKRG WKRG WBRG WBKG WBKR
The 15 twocolor cards are
WB BK KR RG GW WK KW WR RW BR RB BG GB KG GK
For each color there are 7 twocolor pairs that do not contain that color. Here are the pairs that don't contain W:
BK+RG
BR+GK
BR+KG
KR+BG
KR+GB
RB+GK
RB+KG
Thus for a given color there are 1 + 7 = 8 different ways to make a pile that doesn't contain that color since we can either choose the appropriate fourcolour card or one of the 7 twocolour pairs.
Now things start to get tricky.
Here's some Python code that does a brute force search of the 8^{5} = 32768 combinations looking for ones that don't reuse any twocolor cards. It finds 5915 different ways to make the piles.
This code runs on Python 3 or Python 2.7; with slight modifications it can run on older versions of Python 2.
Output:
To get this code to actually list all of the piles just uncomment the #print(piles) line.
The 5 fourcolor cards are
BKRG WKRG WBRG WBKG WBKR
The 15 twocolor cards are
WB BK KR RG GW WK KW WR RW BR RB BG GB KG GK
For each color there are 7 twocolor pairs that do not contain that color. Here are the pairs that don't contain W:
BK+RG
BR+GK
BR+KG
KR+BG
KR+GB
RB+GK
RB+KG
Thus for a given color there are 1 + 7 = 8 different ways to make a pile that doesn't contain that color since we can either choose the appropriate fourcolour card or one of the 7 twocolour pairs.
Now things start to get tricky.
Here's some Python code that does a brute force search of the 8^{5} = 32768 combinations looking for ones that don't reuse any twocolor cards. It finds 5915 different ways to make the piles.
This code runs on Python 3 or Python 2.7; with slight modifications it can run on older versions of Python 2.
Code: Select all
from __future__ import print_function
from itertools import combinations, product
colors = 'WBKRG'
colorset = set(colors)
print(colors)
# Fourcolor cards
col4 = [colors[:i] + colors[i+1:] for i in range(len(colors))]
print(*col4)
groups = {k: [(u,)] for k, u in zip(colors, col4)}
# Twocolor adjacents
col2 = [u + v for u, v in zip(colors, colors[1:] + colors[:1])]
# Add the twocolor nonadjacents
for u, v in combinations(colors, 2):
a, b = u + v, v + u
if not (a in col2 or b in col2):
col2.extend((a, b))
print(*col2)
pairs = []
for u, v in combinations(col2, 2):
k = colorset  set(u + v)
if len(k) == 1:
pairs.append((k.pop(), (u, v)))
pairs.sort()
for k, t in pairs:
groups[k].append(t)
for k in colors:
print(k, groups[k])
# Generate valid piles
good = 0
for piles in product(*[groups[k] for k in colors]):
used = set()
for t in piles:
if len(t) == 2:
s = set(t)
if not used.intersection(s):
used.update(s)
else:
break
else:
#print(piles)
good += 1
print('\nNumber of ways to make the piles =', good)
Output:
Code: Select all
WBKRG
BKRG WKRG WBRG WBKG WBKR
WB BK KR RG GW WK KW WR RW BR RB BG GB KG GK
W [('BKRG',), ('BK', 'RG'), ('BR', 'GK'), ('BR', 'KG'), ('KR', 'BG'), ('KR', 'GB'), ('RB', 'GK'), ('RB', 'KG')]
B [('WKRG',), ('KR', 'GW'), ('RG', 'KW'), ('RG', 'WK'), ('RW', 'GK'), ('RW', 'KG'), ('WR', 'GK'), ('WR', 'KG')]
K [('WBRG',), ('GW', 'BR'), ('GW', 'RB'), ('RW', 'BG'), ('RW', 'GB'), ('WB', 'RG'), ('WR', 'BG'), ('WR', 'GB')]
R [('WBKG',), ('BK', 'GW'), ('KW', 'BG'), ('KW', 'GB'), ('WB', 'GK'), ('WB', 'KG'), ('WK', 'BG'), ('WK', 'GB')]
G [('WBKR',), ('BK', 'RW'), ('BK', 'WR'), ('KW', 'BR'), ('KW', 'RB'), ('WB', 'KR'), ('WK', 'BR'), ('WK', 'RB')]
Number of ways to make the piles = 5915
To get this code to actually list all of the piles just uncomment the #print(piles) line.
Re: Combinatoric commanders
PM 2Ring wrote:I'll represent the colors by their initials, except I'll use the printers' convention of using K for black, so our colors in colorwheel order are WBKRG.
The official convention is to use B for black and U for blue.
gmalivuk wrote:Yes. And if wishes were horses, wishing wells would fill up very quickly with drowned horses.King Author wrote:If space (rather, distance) is an illusion, it'd be possible for one metame to experience both body's sensory inputs.
Re: Combinatoric commanders
Sizik wrote:PM 2Ring wrote:I'll represent the colors by their initials, except I'll use the printers' convention of using K for black, so our colors in colorwheel order are WBKRG.
The official convention is to use B for black and U for blue.
PM 2Ring refers to the CMYK color model, where K stands for Key and is the black color.
In fact, B is quite commonly used for Blue, as in the RGB color model
 WibblyWobbly
 Can't Get No
 Posts: 506
 Joined: Fri Apr 05, 2013 1:03 pm UTC
Re: Combinatoric commanders
Demki wrote:Sizik wrote:PM 2Ring wrote:I'll represent the colors by their initials, except I'll use the printers' convention of using K for black, so our colors in colorwheel order are WBKRG.
The official convention is to use B for black and U for blue.
PM 2Ring refers to the CMYK color model, where K stands for Key and is the black color.
In fact, B is quite commonly used for Blue, as in the RGB color model
Sizik is referring to the longstanding convention in M:tG. Which is more or less the way WotC did it way back in the long long ago (at least, since I started, which was during the Revised/Third Ed. era)
Re: Combinatoric commanders
Sizik wrote:PM 2Ring wrote:I'll represent the colors by their initials, except I'll use the printers' convention of using K for black, so our colors in colorwheel order are WBKRG.
The official convention is to use B for black and U for blue.
Ah, ok.
If you want to run my code using that convention just change the color assignment line from
Code: Select all
colors = 'WBKRG'
to
Code: Select all
colors = 'WUBRG'
Who is online
Users browsing this forum: No registered users and 15 guests