Code
Hub
Workspaces
Connect
Indexed graphs
Engine
MCP
copy
hub
/
github.com/jwasham/practice-python
/ hamming_weight
Function
hamming_weight
bit_manipulation/bits.py:12–21 ·
view source on GitHub ↗
(x)
Source
from the content-addressed store, hash-verified
10
11
# Wegner method
12
def
hamming_weight(x):
13
if
x < 0:
14
return
None
15
16
count = 0
17
while
x:
18
x &= x - 1
19
count += 1
20
21
return
count
22
23
24
def
pop_count(i):
Callers
1
main
Function · 0.85
Calls
no outgoing calls
Tested by
no test coverage detected