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
function isPossible ( r , b , g ) { r = r % 3 ; b = b % 3 ; g = g % 3 ; if ( r == b b == g g == r ) { return true ; } else { return false ; } } var R = 1 , B = 3 , G = 6 ; if ( isPossible ( R , B , G ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }