📅  最后修改于: 2023-12-03 15:10:05.324000             🧑  作者: Mango
这是一款经典的游戏,游戏规则如下:
现在要求你写一个程序,找出该游戏的获胜者。
根据游戏规则,我们可以发现:
def gameWinner(n: int) -> str:
if n % 4 == 0:
return '后手'
else:
return '先手'
assert gameWinner(1) == '先手'
assert gameWinner(3) == '先手'
assert gameWinner(4) == '后手'
assert gameWinner(5) == '先手'
assert gameWinner(6) == '先手'
assert gameWinner(7) == '先手'
assert gameWinner(8) == '后手'
assert gameWinner(9) == '先手'