Check if quantities of 3 distinct colors can be converted to a single color by given merge | Function to check whether it is possible to do the operation or not ; Calculate modulo 3 of all the colors ; Check for any equal pair ; Otherwise ; Given colors ; Function call
def isPossible ( r , b , g ) : NEW_LINE INDENT r = r % 3 NEW_LINE b = b % 3 NEW_LINE g = g % 3 NEW_LINE if ( r == b or b == g or g == r ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT R = 1 NEW_LINE B = 3 NEW_LINE G = 6 NEW_LINE if ( isPossible ( R , B , G ) ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT