Chopsticks Game
InterviewTime limit1sMemory limit512 MB
Given the starting finger counts A and B (1 to 4 each), decide whether the first player Yongtae wins the one-hand chopsticks game under optimal play.
- Level
Medium4 of 10
- Topics
- Game theory, Recursion, Brute force
- Solved
- No attempts yet
Problem
Yongtae and Yujin play a chopsticks game. The game proceeds as follows.
- Yongtae chooses the number of fingers raised on one hand at the start.
- Yujin chooses the number of fingers raised on one hand at the start.
- Starting with Yongtae, the two players take turns attacking the opponent to make the opponent raise more fingers. If a player with fingers raised attacks the opponent, the opponent must raise more fingers.
- The player who must raise five or more fingers loses. The game uses only one hand.
For example, if Yongtae starts with 1 finger raised and Yujin starts with 2, the game goes as follows.
- Yongtae attacks first, so Yujin raises 1 more finger.
- Yujin attacks Yongtae, so Yongtae raises 3 more fingers.
- Yongtae attacks Yujin, so Yujin must raise 7 fingers and loses.
Input
The first line contains (), the number of fingers Yongtae raises on one hand at the start, and (), the number of fingers Yujin raises on one hand at the start.
Output
Print yt if Yongtae wins when both players follow the game as described. Print yj if Yujin wins.