Still have to get used to bitwise operators. But I like this aproach...
This is a very efficient solution. The only change I would recommend is to use n&1 instead of suffering the cost of a division for n%2
This is probably significatively more efficient that dealing with strings and chars.
>> is called 'Right Shift' where it moves (shifts) each bit of the integers binary representation by a set amount of places. The formula is: n // 2 ** x
n >>= 1
n = n >> 1
# Right Bit Shift (>>)
5 >> 4 n >> x = n // 2 ** x
0b0010100 >> 3 == 0b000010 (20 >> 3 = 2)
0b0000010 >> 2 == 0b000000 (2 >> 2 = 0)
Could you tell me what ">>=" means?
I'm assuming it's a bitwise operator but can't find a reference to it anywhere.
I think lambda usage is overkill for this 8 kyu kata =)