As reported: Microsoft (Dec 2025): a rock-paper-scissors tournament problem — the person of interest must win the tournament while changing hand formation as few times as possible.
n players stand in a line. In each round, players are paired in order — positions (0,1), (2,3), … — and each pair plays rock-paper-scissors: Paper beats Rock, Scissors beats Paper, Rock beats Scissors. The winner advances; a tie eliminates both players. If a round has an odd number of players, the last one advances without playing. Rounds repeat with the survivors, in their original order, until one player is left.
Player poi (the person of interest) may pick any hand in each match. Every other player always plays the same hand. formations gives the other players' hands in line order with the POI's slot left out (length n − 1).
Return the minimum number of times the POI must change hand to win the tournament. The POI's first hand is free.
Example 1
n = 3, poi = 2, formations = "PS" -> 0
Players: P S *. Round 1: S beats P; the POI sits out. Round 2: the POI plays R against S.
Example 2
n = 4, poi = 1, formations = "PRS" -> 1
Players: P * R S. Round 1: the POI plays S against P; R beats S. Round 2: the POI plays P against R — one change.
Constraints: 2 ≤ n ≤ 10^5; 0 ≤ poi < n; formations has length n − 1 and only R, P, S.
Clarifications
- If the POI is ever left as the only survivor (others knocked each other out), the POI wins.
Code runner format: one JSON value per line: n, poi, formations. Implement minChanges(n, poi, formations); the harness prints the result.