Find the player to reach at least N by multiplying with any value from given range | Function to find the winner ; Backtrack from N to 1 ; Driver Code
def Winner ( N ) : NEW_LINE INDENT player = True NEW_LINE while N > 1 : NEW_LINE INDENT X , Y = divmod ( N , ( 9 if player else 2 ) ) NEW_LINE N = X + 1 if Y else X NEW_LINE player = not player NEW_LINE DEDENT if player : NEW_LINE return ' B ' NEW_LINE else : NEW_LINE return ' A ' NEW_LINE DEDENT N = 10 NEW_LINE print ( Winner ( N ) ) NEW_LINE