Skip to content

Instantly share code, notes, and snippets.

@ppaulojr ppaulojr/

Created Mar 14, 2017
What would you like to do?
# input bitset array
# output position of the bits that are 1
def parse_string_netfilter(s):
lista = s.split(",")
resp = []
for i,x in enumerate(lista):
b = "{:b}".format(int(x))[::-1]
resp = resp + [int(j)+1+8*int(i) for j,y in enumerate(b) if y=="1"]
return resp
# Test
# Should output [4, 5, 13]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.