{"id":20529,"date":"2021-09-15T19:50:41","date_gmt":"2021-09-15T14:20:41","guid":{"rendered":"https:\/\/python-programs.com\/?p=20529"},"modified":"2021-11-22T18:36:18","modified_gmt":"2021-11-22T13:06:18","slug":"python-program-to-count-minimum-bits-to-flip-such-that-xor-of-a-and-b-equal-to-c","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-count-minimum-bits-to-flip-such-that-xor-of-a-and-b-equal-to-c\/","title":{"rendered":"Python Program to Count Minimum Bits to Flip such that XOR of A and B Equal to C"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Check if a Number has Bits in Alternate Pattern<\/a><\/p>\n

Given an N-bit binary sequence consisting of three binary sequences A, B, and C. Count the minimal number of bits required to flip A and B in such a way that the XOR of A and B equals C.<\/p>\n

X\u00a0 \u00a0 \u00a0 \u00a0Y\u00a0 \u00a0 \u00a0 X XOR Y<\/strong><\/p>\n

0\u00a0 \u00a0 \u00a0 \u00a00\u00a0 \u00a0 \u00a0 \u00a0 0<\/p>\n

0\u00a0 \u00a0 \u00a0 \u00a01\u00a0 \u00a0 \u00a0 \u00a0 1<\/p>\n

1\u00a0 \u00a0 \u00a0 \u00a00\u00a0 \u00a0 \u00a0 \u00a0 1<\/p>\n

1\u00a0 \u00a0 \u00a0 \u00a01\u00a0 \u00a0 \u00a0 \u00a0 0<\/p>\n

Cases:<\/strong><\/p>\n