Track the position of a hidden ball as three shells are repeatedly swapped.
You are given a game with three shells labeled 1, 2, and 3. A ball starts under shell 1. Then a sequence of swaps is performed, where each swap exchanges the positions of two shells. Your task is to determine which shell contains the ball after all swaps are complete.
This is a simple simulation problem: follow every swap in order and keep track of the ball’s current position.
The input consists of:
The ball initially starts under shell $1$.
Print a single integer: the final position of the ball after all swaps are processed.
Example 1
Input
3 1 2 3 2 1 3
Output
2
Explanation
Start with the ball under shell 1.
Final answer: 1
Example 2
Input
2 2 3 1 2
Output
3
Explanation
Start at shell 1.
Final answer: 2
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.