Two blacksmiths, Player1 and Player2, share a single workshop stockpile of forging materials: ingotCount rare ingots and rivetCount common rivets. Starting with Player1, the smiths alternate turns. On the smith's turn, they must forge exactly one enchanted blade, which consumes exactly 1 rare ingot and 4 common rivets from the shared stockpile. If the stockpile does not currently hold at least 1 rare ingot and at least 4 common rivets, the smith whose turn it is cannot forge and immediately loses the duel -- the other smith wins. There is no strategy involved: a smith always forges whenever the stockpile allows it. Determine which smith wins.
A single line with two integers ingotCount and rivetCount.
A single line containing either Player1 or Player2, naming the winner.
Example 1
Input
1 1
Expected
Player2
Explanation
Player1 goes first but the stockpile has only 1 rivet, fewer than the 4 required, so Player1 cannot forge and loses immediately. Player2 wins without ever taking a turn.
Example 2
Input
4 11
Expected
Player2
Explanation
Turn 1 (Player1): stock has 4 ingots and 11 rivets, so they forge, leaving 3 ingots and 7 rivets. Turn 2 (Player2): forges, leaving 2 ingots and 3 rivets. Turn 3 (Player1): needs 4 rivets but only 3 remain, so Player1 cannot forge and loses. Player2 wins.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →