Find winner in game of N balls , in which a player can remove any balls in range [ A , B ] in a single move | Function to find the winner of the game ; Stores sum of A and B ; If N is of the form m * ( A + B ) + y ; Otherwise , ; Input ; Function call
def NimGame ( N , A , B ) : NEW_LINE INDENT sum = A + B NEW_LINE if ( N % sum <= A - 1 ) : NEW_LINE INDENT return " Bob " NEW_LINE DEDENT else : NEW_LINE INDENT return " Alice " NEW_LINE DEDENT DEDENT N = 3 NEW_LINE A = 1 NEW_LINE B = 2 NEW_LINE print ( NimGame ( N , A , B ) ) NEW_LINE