Given a nonempty multiset of
Scissors, output the winning figure according to the special rule.
For a multiplayer RPS, if all three figures come out, usually it's considered a draw. But by that rule, the probability to draw would dramatically increase when there are many and many players.
Let's resolve that by a special rule.
Though defined as a multiset, the input type and format doesn't matter. Valid formats of the input include:
A sequential container with or without guarantee of order
An size-3 array of integers representing the count of each of RPS
Scissors may be encoded by an arbitrary type.
The Special Rule and Output
Let's say \$r\$
Papers, and \$s\$
Scissors-es(?) are given.
If one of them is zero, output the winning figure of the other two.
If none of them is zero, allot them a score by multiplicating the number of themselves and the number of the figure they win to. That is,
Rockgets score \$r×s\$,
Papergets score \$p×r\$, and
Scissorsget score \$s×p\$.
If the scores don't tie, output the figure with the maximum score.
If the scores tie by two figures, output the winning figure amongst the two figures.
Otherwise, output a fourth value indicating draw.
Otherwise, output either the only figure or the fourth value.
The output type and format doesn't matter.
Rule about code golf
Invalid inputs (Empty container, contains a fourth value, etc) fall into don't care situation.
Given the following input:
[Rock, Rock, Rock, Paper, Paper, Scissors, Scissors]
Rock gets score 3×2=6,
Paper gets score 2×3=6, and
Scissors get score 2×2=4. Since
Paper wins to
Rock, the output is