Backtrack from N to 1
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