FastPrepThree-Coin Match Game
Problems/Three-Coin Match Game

Three-Coin Match Game

Jane Street logoJane Street● EasyNEW GRADFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in two Jane Street trading desk operations reports: a 2015 report from the UK and a new grad report posted in 2020 about a phone round in late 2019. Both describe the same game: flip three fair coins, win one pound if they all match, otherwise lose one pound. Both ask whether the game is worth playing, and then how that changes if one coin may be flipped again. Both reports also mention a follow-up on how confident you are in your answer.

Neither report says exactly when the re-flip happens. Here you choose it after seeing the first flip, to maximize your expected payoff. Your function returns the expected value of the game. Any number of coins, re-flipping more than one coin, other stakes, the limits and the tolerance are ours, and the third example is ours.

Our version is about 85% the same as the reported question.

You flip coins fair coins at once. If they all show the same face (all heads or all tails), you win win. Otherwise you lose loss.

After you see the result, and before the game is settled, you may pick up to maxReflips of the coins and flip those again, once. You choose which coins to re-flip (possibly none) to make your expected payoff as large as possible.

Return the expected value of the game when you play this way. A positive value means the game is worth playing. Answers within 1e-6 of the exact value (relative error for values larger than 1 in absolute value) are accepted.

Function

gameValue(coins: int, maxReflips: int, win: int, loss: int) → double

Examples

Example 1

coins = 3maxReflips = 0win = 1loss = 1return = -0.5

All three coins match in 2 of the 8 equally likely results (all heads or all tails), so you win with chance 1/4. The expected value is 1/4 * 1 - 3/4 * 1 = -0.5, so the game is not worth playing.

Example 2

coins = 3maxReflips = 1win = 1loss = 1return = 0.25

With chance 1/4 the coins already match, and you keep them. Otherwise two coins show one face and the third shows the other. Re-flip the odd coin: it matches the other two with chance 1/2. You win with chance 1/4 + 3/4 * 1/2 = 5/8, so the expected value is 5/8 - 3/8 = 0.25. Now the game is worth playing.

Example 3

coins = 4maxReflips = 1win = 3loss = 1return = 0.5

Of the 16 results, 2 already match. In 8 of them one coin differs from the other three, and re-flipping it wins with chance 1/2. In the other 6 the split is two and two, and one re-flip cannot make all four match. You win with chance 2/16 + 8/16 * 1/2 = 3/8, so the expected value is 3/8 * 3 - 5/8 * 1 = 0.5.

Constraints

  • 1 <= coins <= 60
  • 0 <= maxReflips <= coins
  • 1 <= win, loss <= 1000

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

  • Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Revolver: Will the Next Shot Fire?Tower Research Capital · PHONE SCREEN
  • Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Expected Fake-Name CollisionsMercor · PHONE SCREENMercor interview questions
  • One Number Is the Average of the Other TwoSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Count Routes Through a City GridIMC Trading · PHONE SCREENIMC Trading interview questions
  • Extra Coin Win ProbabilityMicrosoft · PHONE SCREENMicrosoft interview questions
  • Count Clean Attendance LogsRippling · PHONE SCREENRippling interview questions
  • Count Array DerangementsInMobi · PHONE SCREENInMobi interview questions
  • Next Pascal Row CoefficientIntuit · OAIntuit interview questions

Interview reports that mention this question

  • Jane Street TDO UK and Hong Kong: 22 Experiences (Part 10 of 10)
  • Jane Street TDOE New Grad Interview Questions: 11 Experiences

Jane Street interview experiences

  • Jane Street TDOE US Final Round: 11 Experiences (Part 5 of 10)
  • Jane Street TDO Phone Math Round: 26 Experiences (Part 9 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)
All Jane Street interview questionsSee Jane Street hiring insights
Saved
class Solution {
    public double gameValue(int coins, int maxReflips, int win, int loss) {
      // Write your code here.
    }
}
Checking account…