The Magic: the Gathering card game has five colours of magical mana: white (W), blue (U), black (B), red (R), and green (G). Cards can be any of the \$2^5=32\$ subsets of these colours. Hereafter 'colours' refer just to the initials
The order that these colours present themselves on cards follows a method using the colours arranged as a pentagon:
W G U R B
The order seeks to minimise the gaps between colours when read clockwise around the pentagon, while making the gaps equal sizes. Ties are broken by starting with
W. There are only eight arrangements with rotational symmetry;
- no colours:
- one colour:
- two adjacent colours:
- two opposite colours:
- three adjacent colours:
- three opposite colours:
- four colours:
- all five colours, start from the top:
You challenge is to create a function/program, which when given a set of colours, outputs their correct order.
This is code golf, so your solution should be as short as possible!
Input format is flexible. As long as it is not relying on the order given, anything is acceptable. Some examples:
- Binary number or bit string of length 5
- A string/array containing each colour, either a substring of 'WUBRG' or arbitrary order
- A set or dictionary for each colour
Output must follow standard output methods to output a string/array of the colours.
For the case of no colours, an empty string/array or
C (colourless) is allowed. Otherwise output must match an entry from the list below. Case doesn’t matter.
For your convenience, here is a list of all possible combinations
C W U B R G WU UB BR RG GW WB UR BG RW GU WUB UBR BRG RGW GWU WBG URW BGU RWB GUR WUBR UBRG BRGW RGWU GWUB WUBRG