Find the triplet from given Bitwise XOR and Bitwise AND values of all its pairs | Function to find the triplet with given Bitwise XOR and Bitwise AND values of all possible pairs of the triplet ; Stores values of a triplet ; Stores a + b ; Stores a + c ; Stores b + c ; Calculate aSUMb ; Calculate aSUMc ; Calculate bSUMc ; Calculate a ; Calculate b ; Calculate c ; Pra ; Prb ; Prc ; Driver Code
def findNumbers ( aXORb , aANDb , aXORc , aANDc , bXORc , bANDc ) : NEW_LINE INDENT a , b , c = 0 , 0 , 0 ; NEW_LINE aSUMb = 0 ; NEW_LINE aSUMc = 0 ; NEW_LINE bSUMc = 0 ; NEW_LINE aSUMb = aXORb + aANDb * 2 ; NEW_LINE aSUMc = aXORc + aANDc * 2 ; NEW_LINE bSUMc = bXORc + bANDc * 2 ; NEW_LINE a = ( aSUMb - bSUMc + aSUMc ) // 2 ; NEW_LINE b = aSUMb - a ; NEW_LINE c = aSUMc - a ; NEW_LINE print ( " a ▁ = ▁ " , a , end = " " ) ; NEW_LINE print ( " , ▁ b ▁ = ▁ " , b , end = " " ) ; NEW_LINE print ( " , ▁ c ▁ = ▁ " , c , end = " " ) ; NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT aXORb = 30 ; aANDb = 0 ; aXORc = 20 ; aANDc = 10 ; bXORc = 10 ; bANDc = 20 ; NEW_LINE findNumbers ( aXORb , aANDb , aXORc , aANDc , bXORc , bANDc ) ; NEW_LINE DEDENT