KatInterview

Pricing Two Coin-Editing Tools in a Four-Coin Game

Math & Bit ManipulationAuto-graded · 13 test cases
EasyAuto-gradedMath & Bit Manipulationprobabilityexpected-valueparity-invariant

Last updated

Compute a baseline expected payoff and the fair prices of two coin-editing tools, using linearity of expectation, a parity invariant, and an absorbing-state argument.

Four-Coin Game and Two Tools

In a game, four fair coins are tossed together and you receive $1 for every coin that ends up showing heads. You are risk-neutral. A tool is offered that lets you modify the coins after you see the first toss. You are asked to value two different tools.

Rules

  • The coins are fair and independent, so each shows heads with probability 1/2.
  • Your final payoff is $1 per head showing when you stop. There are no other costs or payoffs.
  • A tool is used only after you have seen the initial toss. You may use it any number of times, every use is free, and you choose when to stop and collect.
  • A "pair" is any two distinct coins of your choice. You may pick a different pair on each use, based on the current state of the coins (fully adaptive play).
  • The fair price of a tool is the increase in your expected payoff from owning it, assuming you play optimally.

Task

Write a function that takes no arguments and returns a list of three numbers, in this order:

  1. The expected payoff of the game with no tool.
  2. The fair price of the flip tool: each use selects a pair of coins and turns both over deterministically (heads becomes tails and tails becomes heads).
  3. The fair price of the re-toss tool: each use selects a pair of coins and tosses both of them again.

Return plain numbers, so the result for this problem is a list of three floats (or ints that equal them numerically).

Constraints

  • Exactly four coins, all fair and independent.
  • Payoff is $1 per head at the time you stop.
  • Tool uses are free and unlimited, and you act adaptively after seeing the coins.
  • The prices are measured relative to the no-tool expected payoff.
  • The function takes no input and always returns the same three values.

Examples

Example 1

Input: coin_tool_prices()

Output: [2, 1.5, 2]

Hints

Hint 1

Use linearity of expectation for the baseline: each coin contributes the same expected amount, so you do not need to enumerate outcomes.

Hint 2

For the flip tool, look at how a single use changes the number of heads. Is there a quantity that can never change? Then ask which head counts are reachable from each starting class.

Hint 3

For the re-toss tool, the head count can drop temporarily, but uses are free and unlimited. Think about whether the state with all heads can always be reached eventually, and what that implies for the best possible payoff.