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 ; Print a ; Print b ; Print c ; Driver Code
function findNumbers ( aXORb , aANDb , aXORc , aANDc , bXORc , bANDc ) { let a , b , c ; let aSUMb ; let aSUMc ; let bSUMc ; aSUMb = aXORb + aANDb * 2 ; aSUMc = aXORc + aANDc * 2 ; bSUMc = bXORc + bANDc * 2 ; a = Math . floor ( ( aSUMb - bSUMc + aSUMc ) / 2 ) ; b = aSUMb - a ; c = aSUMc - a ; document . write ( " " + a ) ; document . write ( " " + b ) ; document . write ( " " + c ) ; } let aXORb = 30 , aANDb = 0 , aXORc = 20 , aANDc = 10 , bXORc = 10 , bANDc = 20 ; findNumbers ( aXORb , aANDb , aXORc , aANDc , bXORc , bANDc ) ;