I stared at this for an embarrassingly long time.
First, clarify the problem constraints and confirm that you can flip coins. Then, describe the simple strategy: take any H coins, flip them all, and make that one pile; the remaining N-H coins form the other pile. Finally, prove that both piles will have the same number of heads by analyzing the number of heads in the chosen H coins.
Pro tip: Emphasize that the strategy works regardless of which coins you pick, and that the proof relies on a clever invariant: the number of heads in the flipped pile equals the number of tails originally in that pile, which equals the number of heads in the remaining pile.
Restate the problem to ensure understanding: N coins, exactly H heads, unknown positions. You need to split into two piles with equal heads, and you can flip coins.
Select any H coins to form Pile A. Flip every coin in Pile A. The remaining N-H coins form Pile B (no flips).
Let x be the number of heads in Pile A before flipping. Then Pile A has H - x tails. After flipping, Pile A has H - x heads. Pile B originally had H - x heads (since total heads is H). Thus both piles have H - x heads.
Mention that if H = 0, both piles have 0 heads; if H = N, Pile A has all coins, flipped, resulting in 0 heads, and Pile B is empty (0 heads). The strategy works for any H between 0 and N.
Summarize that the solution is simple, deterministic, and requires no knowledge of which coins are heads. Highlight its relevance to data science: algorithmic thinking, invariants, and problem-solving.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.