Data Structure & Algorithm: Level-1 Problem #13. Bash Game

Bash Game is a classic topic. Given a list of N stones, each person can take 1 to m ( m < N) stone at a time, those who can’t take it, lose the game.

Sample Input:

N = 21, m = 3

Sample Output:

Lose

Given the sample input, with 21 stones in total and if you can only take 3 or less stones at a time. The first player is bound to lose.


数据结构和算法:初级练习题 #13 – 巴什博弈


巴什博弈:只有一堆N个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者得胜。

输入样例:

N= 21, m= 3

输出样例:

Win

给定21个物品,每次最多只能取三个物品,那么首先取的人一定赢。


Python Solution

Bash Game