Solve Exact Probability and Expected-Value Exercises
Company: Old
Role: Data Scientist
Category: Software Engineering Fundamentals
Difficulty: hard
Interview Round: Take-home Project
## Solve Exact Probability and Expected-Value Exercises
Work through the following short quantitative problems. Give exact simplified fractions when the answer is rational, show the sample space or expectation being used, and use decimal notation only when the question asks for a monetary expectation.
### Constraints & Assumptions
- Dice and coins are fair and independent unless a condition explicitly changes the sample space.
- A standard deck has 52 cards, including four jacks, and cards are drawn without replacement.
- When two objects or people are paired, count an unordered pair once.
- Monetary gains are positive and losses are negative.
- Explain enough intermediate reasoning that an arithmetic answer can be checked without simulation.
### Part 1 — Count Equally Likely Outcomes
Answer all five questions:
1. What is the probability that two six-sided dice sum to `8`?
2. If 26 people each shake hands with every other person exactly once, how many handshakes occur?
3. Two distinct numbers are drawn uniformly without replacement from `1` through `15`. What is the probability that their sum is odd?
4. What is the probability that the first two cards drawn from a shuffled standard deck are both jacks?
5. What is the probability that five fair coin flips are all the same face?
#### What This Part Should Cover
- A complete denominator of equally likely outcomes.
- No double-counting of unordered pairs.
- The parity condition for an odd sum.
- Dependence between card draws without replacement.
- Simplified exact results.
```hint Count first, simplify last
Write the favorable and total outcome counts before reducing each fraction.
```
### Part 2 — Condition Before Counting
Two fair six-sided dice are rolled. Given that their sum is `9`, what is the probability that at least one die shows `5`?
#### What This Part Should Cover
- The ordered outcomes that remain possible after conditioning on the sum.
- The favorable outcomes within that reduced sample space.
- Why outcomes excluded by the condition cannot stay in the denominator.
```hint Replace the original sample space
List only the ordered rolls whose sum is nine, then count how many include a five.
```
### Part 3 — Compute Three Expected Values
Answer all three questions:
1. An item is defective with probability `1/50`. Selling a good item earns `\$3`, while a defective item loses `\$75`. What is the expected profit per item?
2. A card numbered uniformly from `1` through `30` pays six times its number in dollars. What is the expected payout?
3. Two fair coins are flipped. Each head earns `\$2`, but the double-tail outcome instead loses `\$7`. What is the expected payoff?
#### What This Part Should Cover
- A complete probability-weighted payoff table.
- Correct signs for gains and losses.
- Linearity of expectation where it shortens the calculation.
- A final monetary expectation for each question.
```hint Include every payoff branch
An expectation is reliable only when the probabilities in its payoff table sum to one.
```
### Part 4 — Compare Competing Coin Patterns
A fair coin is flipped repeatedly until either `HHH` or `TTTT` first appears as a consecutive pattern. What is the probability that `HHH` appears first?
#### What This Part Should Cover
- States that retain the suffix information relevant to either target pattern.
- Equations for transitions after the next head or tail.
- Absorbing success and failure states.
- An exact simplified probability from the initial state.
```hint Keep only useful suffixes
After each flip, the future depends on the longest current suffix that could still grow into one of the two target patterns.
```
### What a Strong Answer Covers
- Uses exact counting or state equations rather than unexplained decimal approximations.
- Makes conditional denominators and dependent draws explicit.
- Separates outcome probabilities from their payoffs in expectation calculations.
- Checks each result with a range or symmetry sanity check.
### Follow-up Questions
1. How would the dice answers change if the dice were distinguishable but not fair?
2. How can exact rational arithmetic prevent rounding errors in a timed implementation?
3. What state changes are needed to compare `HTH` with `THTT` instead?
4. When is linearity of expectation useful even though the underlying events are dependent?
Quick Answer: Work through exact counting, conditional probability, and expected-value exercises involving dice, handshakes, parity, cards, coins, and monetary payoffs. The final pattern race tests state-based reasoning, while the full set rewards checkable sample spaces, simplified fractions, correct signs, and sanity checks.