OFFSET
0,13
PROG
(Python)
def count_zero_runs_in_binary(n):
binRep = bin(n)[2:] # as binary, but ignore "0b" prefix
zRuns = binRep.split('1') # split on the 1's
zRvec = [run for run in zRuns if run] # filter "" to get runs of 0
return len(zRvec)
out = []
for i in range(100):
gv = i ^ (i>>1) # gray code
ans = count_zero_runs_in_binary(gv)
out.append(ans)
print(out)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
James S. DeArmon, May 22 2024
STATUS
approved