Challenge
Bar Dice is a simple game played in a Bar with Dice (hence the name). You roll 5 six-sided dice and attempt to make the best hand.
Scoring is based on amassing the largest number of dice with the same digits. Each hand must include at least a single "Ace", or one, in order to be a valid hand; Aces act as "wilds", and can be paired with any other digit. The strength of a player's hand depends first on the number of digits and then value of those digits. As an example, a hand (counting wilds) with four 3's is better than a hand with three 5's, but not better than a hand with five 2's.
Taken from the Wikipedia article
This means the highest ranked hand is made entirely of 6's and 1's, and the lowest ranked is any hand without a 1.
Your challenge is to take two hands and return which player won, or if they tied.
Input
Two unsorted lists of 5 numbers, ranging from 1 to 6. Each list represents a player's hand. The input format is flexible.
Output
Any three distinct but consistent, static values (ranges are not allowed) signifying whether player 1 or player 2 won, or if it was a tie. Please state in your answer what values you are using for what. For example, you can return -1
if P1 wins, 0
if it's a tie, and 1
if P2 wins.
Rules
- Input will always be valid
- Only the best possible score of each hand is used to determine a winner. There are no tie-breakers. E.g.,
[1,4,4,3,3]
will tie[1,4,4,2,2]
instead of using the 3's and 2's as a tie-breaker. - Output must be one of the 3 chosen values every time. Simply mapping all negative numbers to
P1 Wins
is not allowed and must be normalized. - Invalid hands, i.e. those with no 1's, lose to all valid hands but tie with all other invalid hands. E.g.,
[2,2,2,2,2]
ties[3,3,3,3,3]
. - A hand of
[1,1,1,1,1]
counts as a valid set of 6's for ranking purposes. - This is code-golf so shortest byte count wins.
Examples
#You guys are pretty good at finding edge-cases that break things. Good job!
Input: [2,1,5,6,6], [6,2,6,6,6]
Output: P1 Wins
Input: [2,4,5,6,6], [6,2,6,6,6]
Output: Tie
Input: [1,2,3,4,5], [5,4,3,2,1]
Output: Tie
Input: [1,5,5,3,2], [5,4,1,6,6]
Output: P2 Wins
Input: [3,2,2,2,1], [4,1,3,6,6]
Output: P1 Wins
Input: [1,1,1,1,1], [6,1,1,6,6]
Output: Tie
Input: [1,3,3,4,4], [1,2,2,5,5]
Output: P2 Wins
Input: [1,3,3,5,5], [1,3,3,2,2]
Output: P1 Wins
Input: [1,3,3,3,4], [1,1,3,3,3]
Output: P2 Wins
Input: [2,2,2,6,1], [5,3,3,1,2]
Output: P1 Wins
Input: [5,5,5,1,5], [1,1,1,1,1]
Output: P2 Wins
Input: [1,1,1,1,1], [1,1,5,1,1]
Output: P1 Wins