## 13377 - bbits ## Brief find the minimum flips required in 3 positive integers x,y,z. Such that (X OR Y == Z), a bitwise OR operation. ## Input Input is three positive integers, x, y, z. 0 < x,y,z < 109 ## Output Output is minimum number of flips to make x OR y == z Don't forget to include "\n" ## Solution ```c= //by Mary Madeline #include<stdio.h> int minFlips(int a, int b, int c){ int difference = (a | b) ^ c; int num = difference; int i= 0; int flips = 0; while (num){ /* calculate only for misplaced bits */ if(difference & (1<<i)){ // case for 1 condition and 0 condition if(c & (1<<i)){ flips += 1; } else{ if(a & (1<<i)) flips += 1; if(b & (1<<i)) flips += 1; } } i += 1; num >>= 1; } return flips; } int main(){ int x,y,z; scanf("%d %d %d", &x, &y, &z); printf("%d\n", minFlips(x,y,z)); } ```