Order of Mia Sets
JavaScript (ES6), 162 bytes
(a,b,g=a=>a.map(n=>e[n]=e[n]+1||1,e=[1])&&[[...e].every(n=>n==1),...e.filter(i=x=>x).sort(h=(a,b)=>b-a),...a.sort(h)],c=g(a),d=g(b))=>d.map((n,i)=>n-c[i]).find(i)
Explanation: Takes two arrays as parameters. g
converts each array into a list of counts. The list is then checked to see whether it corresponds to a set 1..n
. The counts are sorted and the sorted values are concatenated. The two results are then compared. The return value is a positive integer if the second array wins and a negative integer if the first array wins, otherwise the falsy JavaScript value undefined
is returned.
Jelly, 16 bytes
ṢŒrUṢṚZ
Ṣ⁼J;ǵÐṀ
Takes a list of lists each of which represents a roll (so can be more than two if wanted) and returns a list of the winner(s).
Try it online! ...alternatively here is a version which sorts the rolls from weakest to strongest instead.
How?
Ṣ⁼J;ǵÐṀ - Main link: list of list of dice rolls, L
µÐṀ - filter keep maximal (i.e. sort L by the previous link as a key and keep maximums)
- e.g. [5,3,1,3]
Ṣ - sort roll [1,3,3,5]
J - range(length(roll)) [1,2,3,4]
⁼ - equal? [1,2,3,...n] beats everything 0
Ç - call last link as a monad with input roll [[2,1,1],[3,5,1]]
; - concatenate [0,[2,1,1],[3,5,1]]
ṢŒrUṢṚZ - Link 1, rest of sort key: dice rolls e.g. [5,3,1,3]
Ṣ - sort the roll [1,3,3,5]
Œr - run length encode [[1,1],[3,2],[5,1]]
U - upend (reverse each) [[1,1],[2,3],[1,5]]
Ṣ - sort [[1,1],[1,5],[2,3]]
Ṛ - reverse [[2,3],[1,5],[1,1]]
Z - transpose [[2,1,1],[3,5,1]]
- ...this is a list of: 1) the group sizes descending; and
2) the face values of each group, descending across equal group sizes