FastPrepExact-Sixty Dice Game Value

Exact-Sixty Dice Game Value

Jane Street logoJane Street● EasyINTERNONSITE INTERVIEW
Learn

Problem statement

Choose one available fair die and roll it once. A die with s sides has equally likely integer faces from 1 through s. The roll costs 1, and rolling exactly 60 pays 100.

Return the side count with the greatest exact expected net value as side|numerator/denominator, where the reduced fraction is also the fair midpoint for the round. Ties choose the smaller side count. Dice with fewer than 60 sides can never win the payout and therefore have net value -1/1.

Function

bestExactSixtyDie(sideCounts: int[]) → String

Examples

Example 1

sideCounts = [10,20,30,40,50,60,70,80,90,100]return = "60|2/3"

The 60-sided die has net expectation 100/60 - 1 = 2/3, larger than every other available die.

Example 2

sideCounts = [6,20,50]return = "6|-1/1"

No die can roll 60, so every option has net value -1 and the smallest side count wins the tie.

Constraints

  • 1 <= sideCounts.length <= 10^5.
  • 1 <= sideCounts[i] <= 10^9.
  • Side counts may repeat.

More Jane Street problems

See Jane Street hiring insights
public String bestExactSixtyDie(int[] sideCounts) {
    // Write your code here.
}
sideCounts[10,20,30,40,50,60,70,80,90,100]
expected"60|2/3"
Checking account…