Skip to content

Instantly share code, notes, and snippets.

@9terz
Created September 22, 2018 18:13
Show Gist options
  • Save 9terz/f418b550fc700c9a661ab01c609ccdb3 to your computer and use it in GitHub Desktop.
Save 9terz/f418b550fc700c9a661ab01c609ccdb3 to your computer and use it in GitHub Desktop.
bingap
def bingap(num):
binary = str(bin(num))[2:]
print("binary is {}".format(binary))
numlist = binary.split('1')
return len(max(numlist, key=len))
print(bingap(6666))
@bact
Copy link

bact commented Sep 22, 2018

เออว่ะ ใช้ split ได้นี่หว่า

@bact
Copy link

bact commented Sep 22, 2018

เอาไอเดียเฟ้นมาปรับนิดนึง

def bingap(num):
    numlist = bin(num)[2:].split('1')
    return len(max(numlist[:-1] if '0' in numlist[-1] else numlist, key=len))

@9terz
Copy link
Author

9terz commented Sep 22, 2018

this code failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment