Solutions for Flipping

    • @Victorfreef
    • @Liam, submitted in Python 2, achived 100% score
    def countSetBits( n ): 
        count = 0
        while n: 
            count += 1
            n &= (n-1) 
        return count 
    
    # Function that return count of 
    # flipped number 
    def solve(a , b): 
    
        # Return count of set bits in 
        # a XOR b 
        return countSetBits(a^b) 
    
    • @Victorfreef
    • @Liam, submitted in Python 3, achived 100% score
    def countSetBits( n ): 
        count = 0
        while n: 
            count += 1
            n &= (n-1) 
        return count 
    
    # Function that return count of 
    # flipped number 
    def solve(a , b): 
    
        # Return count of set bits in 
        # a XOR b 
        return countSetBits(a^b)