A Garmin wearable or navigation device may store status flags and sensor data in a 32-bit unsigned value. Given such an integer n, return the number of binary 1 bits in its representation.
Use an efficient bit-manipulation approach rather than converting the value to a string. The input is always a non-negative unsigned 32-bit integer, so leading zeroes do not affect the result.
n where 0 <= n < 2^32.n.count_set_bits(n).def count_set_bits(n):