The dice game Mia introduces a very non-trivial order of sets of size two:
{3,1} < {3,2} < {4,1} < {4,2} < {4,3} < {5,1} < {5,4} < {6,1} < {6,5} < {1,1} < {2,2} < {6,6} < {1,2}
In general, the order within a tuple does not matter {x,y}={y,x}
,
{1,2}
is greater than anything else,
Pairs are greater than non-pairs and the numeric value decides in case of a tie.
Now suppose you want to use n
dice. Also, the dices have m
faces.
Example:
{1,5,3,4} < {1,2,6,3}
since 5431 < 6321{1,2,3,5} < {1,1,5,6} < {1,1,5,5}, {1,1,6,6} < {1,1,1,3} < {2,2,2,3} < {1,1,1,1} < {1,2,3,4}
{2,2,5} < {1,1,6}
since both sets have each one pair and 611 > 522
In a nutshell, {1, ..., n}
is greater than anything else.
Let p > q
, then p-of-a-kind is greater than q-of-a-kind.
In case of a tie, the second(, third, ...)-longest of-a-kind wins.
Finally, if no decision could be made yet, the greatest numerical value wins.
The numerical value of a set is the largest integer you can build from the available numbers in the set, using concatenation. Example:
{2,5,4,3}
becomes 5432{4,11,3,4}
becomes B443 (>6-faced dice are allowed, B=11)
Your task is to write the smallest possible program (i.e. function) in the language of your choice, that, given two containers (list, array, set, ...) returns whether the first or the second one wins.
Note: you can assume that the two containers have the same length and contain only positive integers, but nothing else. Especially they may be not sorted. The return value could be anything, e.g. {-1, 0, 1} for {first wins, tie, second wins}.
{1,1,6}
,{2,2,5}
? Do you compare the numerical value of the largest p-of-a-kind or of any dice? \$\endgroup\$