Determine winner of the Game by arranging balls in a row | Function to find the winner of the Game by arranging the balls in a row ; Check if small balls are greater or equal to the large ones ; X can place balls therefore scores n - 1 ; Condition if large balls are greater than small ; X can have m - 1 as a score since greater number of balls can only be adjacent ; Compare the score ; Driver Code ; Given number of small balls ( N ) and number of large balls ( M ) ; Function call
def findWinner ( n , m ) : NEW_LINE INDENT X = 0 ; NEW_LINE Y = 0 ; NEW_LINE if ( n >= m ) : NEW_LINE INDENT X = n - 1 ; NEW_LINE Y = m ; NEW_LINE DEDENT else : NEW_LINE INDENT X = m - 1 ; NEW_LINE Y = n ; NEW_LINE DEDENT if ( X > Y ) : NEW_LINE INDENT print ( " X " ) ; NEW_LINE DEDENT elif ( Y > X ) : NEW_LINE INDENT print ( " Y " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( " - 1" ) ; NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n = 3 ; NEW_LINE m = 1 ; NEW_LINE findWinner ( n , m ) ; NEW_LINE DEDENT