Changyeong Village Cup Shuffle
InterviewTime limit1sMemory limit128 MB
Track the position of a ball among three cups after a sequence of swap operations described by characters A, B, C.
- Level
Easy2 of 10
- Topics
- Simulation, String
- Solved
- No attempts yet
Problem
Three opaque cups are placed in positions 1, 2, and 3 from left to right. At first, a small ball is under the cup in the leftmost position.
Jeongin repeatedly chooses one of the following moves and swaps the cups in the two indicated positions.
A: swap the cups in positions 1 and 2.B: swap the cups in positions 2 and 3.C: swap the cups in positions 1 and 3.
Given the sequence of moves in order, determine which position contains the ball after all moves are performed.
Input
The first line contains a string describing the sequence of cup moves. Each character is one of A, B, and C, and the string length is between 1 and 50 inclusive.
Output
Print 1 if the ball is in the leftmost position, 2 if it is in the middle position, and 3 if it is in the rightmost position.