• + 3 comments

    All of my tests pass except test case 0:

    def findConnectedComponents(d):
        sols = 0
        for bit in range(64):
            n_unset = sum(i & (1 << bit) == 0 for i in d)
            sols += 2 ** n_unset
        return sols + 2 ** len(d) - 1
    

    I count all the subsets in which each particular bit will be unset, thus solitary. Then

    add 1 for all subset, except the empty set, to count the cnon solitary components