FastPrepAll Even Faces Before the First Odd Roll
Problems/All Even Faces Before the First Odd Roll

All Even Faces Before the First Odd Roll

IMC Trading logoIMC Trading● EasyINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported oral question asks for every even die face to appear before the first odd result; the core event matches at about 90%. Fair independent rolls, consecutively numbered faces, variable even side counts, bounds and numeric tolerance are explicit practice assumptions. Repeated even faces do not end the process. The report does not confirm a numerical answer or request an implementation.

You roll a die again and again. Find the probability that every even-numbered face appears at least once before the first odd-numbered result.

The die is fair and has sides faces, where sides is even. The faces are numbered from 1 through sides. Every roll is independent of the others. You may roll an even face you have already seen. That does not erase the even faces seen so far. The rolling stops at the first odd result. If an odd result comes before every even face has appeared, you fail.

A usual die has six faces. Here the number of faces is the input sides. Complete allEvenBeforeOddProbability(sides). Return the probability as a double, without rounding.

Your answer is accepted when abs(actual - expected) <= 1e-9 * max(1, abs(expected)).

Function

allEvenBeforeOddProbability(sides: int) → double

Examples

Example 1

sides = 6return = 0.05

This is the usual six-sided die. Rolls that repeat an even face you have already seen change nothing, so skip them. At the start, the next useful roll is even with chance 3/6. After each new even face, that chance drops to 2/5 and then 1/4. Multiply them to get the answer: 1/20 = 0.05.

Example 2

sides = 2return = 0.5

Here the die has only one even face, 2. You succeed only if the very first roll is that face. That happens half the time, so the answer is one half.

Example 3

sides = 4return = 0.16666666666666666

You need to see both 2 and 4 before any 1 or 3. The first roll must be even. Then, skipping repeats of that face, the next new face must be the other even one. So the answer is (2/4)*(1/3) = 1/6.

Constraints

  • 2 <= sides <= 20, and sides is even.
  • Each face has probability 1/sides on every independent roll.
  • To succeed, all sides/2 different even faces must appear before any odd result.

More IMC Trading Phone Screen questions

  • Election District Budget Allocation AnalysisPHONE SCREEN · Seen Aug 2026
  • Uniform Variables: Smaller Below Larger SquaredPHONE SCREEN · Seen Mar 2026
  • Combination Sum with Unlimited ReusePHONE SCREEN · Seen Dec 2025
  • Valid Range of a Three-Outcome Probability ParameterPHONE SCREEN · Seen Dec 2025
  • Expected Fishing CatchPHONE SCREEN · Seen Dec 2025
  • Count Routes Through a City GridPHONE SCREEN · Seen Nov 2024
  • Expected City Arrival and Return DaysPHONE SCREEN · Seen Nov 2024
  • Stationary City Population SharesPHONE SCREEN · Seen Nov 2024
  • Maximum Falling Path SumPHONE SCREEN · Seen Nov 2024
  • Trading Profit Percentage ChangePHONE SCREEN · Seen Feb 2024

Similar questions at other companies

  • Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREEN
  • Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREEN
  • Heads in Fair Coin FlipsJane Street · PHONE SCREEN
  • Strictly More Heads with Fewer CoinsSusquehanna International Group (SIG) · PHONE SCREEN
  • Count Clean Attendance LogsRippling · PHONE SCREEN
  • Count Array DerangementsInMobi · PHONE SCREEN
  • Count Staircases with Strictly Increasing StepseBay · ONSITE INTERVIEW
  • Count Nondecreasing Digit-Sum ArraysMicrosoft · OA
  • Stable Workload Redistribution TreesTower Research Capital · OA
  • Count Valid A-B-C Sequences Under a Modulo-Four RuleInfosys · OA
See IMC Trading hiring insights
Saved
class Solution {
    public double allEvenBeforeOddProbability(int sides) {
        // Write your solution here.
    }
}
Checking account…