Compute expected days until no whole pills
Company: Qube
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Technical Screen
A bottle initially contains **H half-pills** and **W whole pills**.
Each day:
1. You randomly select **one pill uniformly** from the bottle.
2. If it is a **half-pill**, you consume it entirely (it is removed).
3. If it is a **whole pill**, you consume **half** and put the **remaining half** back into the bottle. (So selecting a whole pill decreases the number of whole pills by 1 and increases the number of half-pills by 1.)
You always consume exactly **half a pill per day**.
Task: **Compute the expected number of days until the bottle contains no whole pills** (i.e., only half-pills remain).
### Input
- Two integers `H` and `W`.
### Output
- A floating-point number: the expected number of days until `W = 0`.
### Example instance
- `H = 25`, `W = 25`.
### Constraints (for your implementation)
- You may assume `0 ≤ H, W ≤ 200` (or similar), and you should output the expectation with reasonable precision (e.g., `1e-6`).
Quick Answer: This question evaluates understanding of probability and expected value, modeling of state-based stochastic processes (Markov chains), and the ability to represent state transitions for computing hitting times in an algorithmic context.
Return expected days until W whole pills reaches zero under uniform random selection.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: (0, 1)
Expected Output: 1.0
Explanation: One whole pill must be selected once.
Input: (1, 1)
Expected Output: 1.5
Explanation: May pick half first or whole first.
Input: (25, 25)
Expected Output: 70.222503
Explanation: Prompt-sized example.
Hints
- Choose a representation that makes the requested operation direct.
- Handle empty inputs and boundary cases first.