Under construction

Still being built. Things may change

Six Sides

Interview

Time limit1sMemory limit512 MB

Summary
Given the six faces of two dice, find the probability that the first die shows the higher value, ignoring ties by rethrowing.
Level

Easy3 of 10

Topics
Probability, Math, Implementation
Solved
No attempts yet

Problem

Two players play a simple game. Each brings one six-sided die with a value written on every face. Both dice are fair, so when a die is thrown each of its six faces is equally likely to land on top.

The first player throws the first die and the second player throws the second die. If the two values on top differ, the player with the larger value wins. If the values are the same, both players throw again.

Given the values written on the two dice, compute the probability that the first player wins.

Input

The first line contains six space-separated integers, the values written on the six faces of the first player's die.

The second line contains the values on the second player's die in the same format.

Every value is between 11 and 66, inclusive.

Output

Print on a single line the probability that the first player wins, rounded to exactly five digits after the decimal point, with one digit before the decimal point and five digits after it. The sixth digit after the decimal point of the exact answer is never 44 or 55, so the rounding direction is unambiguous.

If the two dice always show the same value, the game never ends and the first player never wins. Print 0.00000 in that case.

Examples2

  1. Example 1

    Input
    1 2 3 4 5 6
    1 2 3 4 5 6
    
    Expected output
    0.50000
    
  2. Example 2

    Input
    4 4 4 4 1 1
    3 3 3 3 3 3
    
    Expected output
    0.66667