Beating any pattern your opponent picks
Asked at Jane Street
In Penney's game, your opponent first commits to a three-flip pattern, then you choose yours, and you flip a fair coin until one pattern appears. Suppose your opponent picks HTH.
What should you pick, what is your winning probability, and why does this always work?
Show a hint
There is a fixed recipe for the second player. And there is a clean way to compute the odds of one pattern beating another from how the patterns overlap.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.