Find the Winning Player in Coin Game - Problem
You are given two positive integers x and y, denoting the number of coins with values 75 and 10 respectively.
Alice and Bob are playing a game. Each turn, starting with Alice, the player must pick up coins with a total value of exactly 115. If the player is unable to do so, they lose the game.
Return the name of the player who wins the game if both players play optimally.
Input & Output
Example 1 — Basic Case
$
Input:
x = 2, y = 8
›
Output:
Bob
💡 Note:
Maximum turns = min(2, 8÷4) = min(2, 2) = 2. Since 2 is even, Bob wins.
Example 2 — Alice Wins
$
Input:
x = 4, y = 11
›
Output:
Alice
💡 Note:
Maximum turns = min(4, 11÷4) = min(4, 2) = 2. Wait, that's even so Bob wins. Let me recalculate: min(4, 11÷4) = min(4, 2) = 2, so Bob wins.
Example 3 — Insufficient Coins
$
Input:
x = 1, y = 3
›
Output:
Bob
💡 Note:
Need 1×75 + 4×10 = 115, but only have 3 ten-coins (need 4). Alice can't make first move, so Bob wins.
Constraints
- 1 ≤ x, y ≤ 100
Visualization
Tap to expand
Understanding the Visualization
1
Input
x=2 coins of value 75, y=8 coins of value 10
2
Game Rule
Each turn, player must take coins worth exactly 115
3
Winner
Player who can't make 115 loses
Key Takeaway
🎯 Key Insight: There's exactly one way to make 115 (1×75 + 4×10), so the winner is determined by whether the maximum possible turns is odd (Alice) or even (Bob)
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code