Hard logic-puzzles interview practice: Pure Gold.
Explore this problem with a Quantercise subscription.