Created
June 6, 2020 14:15
-
-
Save ra312/22d5239f210494520034e6e5ec1ae579 to your computer and use it in GitHub Desktop.
counting pairs with bitwise product
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
def countPairs(arr): | |
# Write your code here | |
count = 0 | |
for i, j in itertools.combinations(arr, 2): | |
v = i & j | |
if v != 0 : | |
if (v % 2 == 0) | (v == 1): | |
count+=1 | |
return count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment