Multiplayer Rock-Paper-Scissors Objective

Given a nonempty multiset of Rock, Paper, and Scissors, output the winning figure according to the special rule.

Background

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.

Input

Though defined as a multiset, the input type and format doesn't matter. Valid formats of the input include:


A multiset
A sequential container with or without guarantee of order
An size-3 array of integers representing the count of each of RPS


Also, Rock, Paper, and Scissors may be encoded by an arbitrary type.

The Special Rule and Output

Let's say \$r\$ Rocks, \$p\$ 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, Rock gets score \$r×s\$, Paper gets score \$p×r\$, and Scissors get 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.

Example

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 Paper.
Python, 41 bytes



lambda r,s,p:[s&gt;p&lt;=r&gt;0,p&gt;r&lt;=s&gt;0,r&gt;s&lt;=p&gt;0]


Try it online!

Takes counts as (r,s,p). Outputs a three-element list with True at the position of the winner, or all False's if there's a tie or only a single figure appearing.

Rock:     [True, False, False]
Scissors: [False, True, False]
Paper:    [False, False, True]
Tie:      [False, False, False]


We use an alternate characterization without multiplication (except when only one figure is present). Below is the condition for Rock winning, with Scissors and Paper having similar conditions.


  Rock wins if: Paper has the fewest, strictly fewer than Scissors but possibly the same as Rock.


We can write this in Python as s&gt;p&lt;=r using inequality chaining.

Unfortunately, this doesn't correctly handle the special case when r=p=0, saying that Rock wins even though only Scissors is present. To fix this, we strengthen the condition for Rock to win to include r&gt;0 via s&gt;p&lt;=r&gt;0, which makes the only-Scissors case give all False for every condition, matching a tie. 



44 bytes



lambda r,s,p:r*s==s*p==p*r or[s&gt;p&lt;=r,p&gt;r&lt;=s]


Try it online!

Takes counts as (r,s,p). Outputs as:

Rock:     [True, False]
Scissors: [False, True]
Paper:    [False, False]
Tie:      True    


The "Tie" case also includes where there's only a single figure present.