Chance a Face Shows on At Least K Dice
Updated
Problem statement
You roll n fair dice at once. Each die has sides faces numbered 1 to sides, every face is equally likely, and the dice do not affect each other.
Fix one face value X before the roll. Return the probability that X shows on at least k of the dice. The answer is the same for every choice of X, so X is not an input.
Answers within 10-6 of the correct value are accepted.
Function
diceFaceProbability(n: int, sides: int, k: int) → doubleExamples
Example 1
n = 3sides = 6k = 1return = 0.4212962962962963Each die misses the chosen face with chance 5/6, so all three miss with chance 125/216. At least one shows it with chance 1 - 125/216 = 91/216, about 0.4213.
Example 2
n = 2sides = 6k = 2return = 0.027777777777777776Both dice must show the face: 1/6 * 1/6 = 1/36.
Example 3
n = 5sides = 2k = 3return = 0.5Two-sided dice act like fair coins. Of the 32 equally likely rolls, 10 + 5 + 1 = 16 show the face on at least three dice, so the answer is 1/2.
Constraints
1 <= n <= 10002 <= sides <= 1001 <= k <= n
More Jane Street Phone Screen questions
- Maximum-Scoring Consecutive Tree LevelsPHONE SCREEN · Seen Nov 2026
- Tree Selection and VisibilityPHONE SCREEN · Seen Nov 2026
- Load/Store Arithmetic InterpreterPHONE SCREEN · Seen Oct 2026
- Instrument Stack Language JumpsPHONE SCREEN · Seen Oct 2026
- Run a Stack Language InterpreterPHONE SCREEN · Seen Oct 2026
- Positive-Integer Expression EvaluationPHONE SCREEN · Seen Oct 2026
- Add Two Integers Given as StringsPHONE SCREEN · Seen Sep 2026
- Angle Between Clock HandsPHONE SCREEN · Seen Jul 2026
- Route Length From Two CyclistsPHONE SCREEN · Seen Jul 2026
- Sort TradesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
Similar questions at other companies
- Dice-Walk Winning ProbabilityGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- 3D Grid Diagonal Walk ProbabilityApple · PHONE SCREENApple interview questions
- Coin Game From The EndsTekion · PHONE SCREENTekion interview questions
- Median of Uniform Draws in an IntervalSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
- Starting Value with the Longest Collatz ChainZipRecruiter · PHONE SCREENZipRecruiter interview questions
- Count Array DerangementsInMobi · PHONE SCREENInMobi interview questions
- Maximum-Product Subarray with an Empty ChoiceAkuna Capital · PHONE SCREENAkuna Capital interview questions
- Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Count Staircase WaysGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
- New 21 Game ProbabilityUiPath · PHONE SCREEN
Interview reports that mention this question
Jane Street interview experiences
- Jane Street TDO UK and Hong Kong: 22 Experiences (Part 10 of 10)
- Jane Street TDOE US Final Round: 11 Experiences (Part 5 of 10)
- Jane Street TDOE UK Phone Screen: 15 Experiences (Part 4 of 10)
- Jane Street TDO Excel and VBA Test: 23 Experiences (Part 8 of 10)
- Jane Street TDOE UK Coding Round: 15 Experiences (Part 3 of 10)