Mia is a dice game for two players. Each roll consist of
two dice. Mia involves bluffing about what a player has rolled,
but in this problem we focus only on its scoring rules. Unlike
most other dice games, the score of a roll is not simply the
sum of the dice.
Instead, a roll is scored as follows:
-
Mia ( or
) is always
highest.
-
Next come doubles (, , and so on). Ties are broken
by value, with
being highest.
-
All remaining rolls are sorted such that the highest
number comes first, which results in a two-digit number.
The value of the roll is the value of that number, e.g.
and becomes .
Player and
each roll two dice.
You are asked to compute the odds that player 1 will win given
partial knowledge of both rolls.
Input
The input will contain multiple, different test cases. Each
test case contains on a single line four symbols where
represent the
dice rolled by player
and represents
the dice rolled by player . A ‘*’
represents that the value is not known, otherwise a digit
represents the value of the dice. The input will be terminated
by a line containing
zeros.
Output
For each test case output the odds that player will win. If the odds are
or , output or . Otherwise, output the odds in the
form where
and represent the nominator and
denominator of a reduced fraction (i.e., in lowest terms).
Sample Output Explanation
For * * 1 2, the best player
can do is tie, so his
chance of winning is .
For 1 2 * *, player wins unless player rolls a Mia, which happens
out of times. For 1
2 1 3, 3 1 2 1, and 6 6 6 6 the result is already known. For
* 2 2 2, player wins only if she rolls a
. For * 2 * 6, player wins if he rolls a . If he rolls a , he wins with probability
. He loses if he
rolls a , , or . If he rolls a he wins only if player
rolls a . Thus, his chance of winning is
. When no dice are known, Player
will win in
of all possible
outcomes. Player
will lose in
cases, and there are
possible ties. Thus,
her chance of winning is .
Sample Input 1 |
Sample Output 1 |
* * 1 2
1 2 * *
1 2 1 3
3 1 2 1
6 6 6 6
* 2 2 2
* 2 * 6
* * * *
0 0 0 0
|
0
17/18
1
0
0
1/6
1/3
205/432
|