You are viewing a single comment's thread. Return to all comments →
Hello everyone this is my solution in python3
def to_binary(n): if n == 0: return "0" elif n == 1: return "1" else: return to_binary(n//2) + str(n % 2) def cont(string, curr=0, res=0): if not string: return res if string[0]=='1': curr += 1 else: res = max(curr, res) curr = 0 res = max (curr, res) return cont(string[1:], curr, res) def main(): n = int(input().strip()) str1 = to_binary(n) larg = int(len(str1)) #print (str1) print(cont(str1)) return 0 if __name__ == '__main__': main()
Seems like cookies are disabled on this browser, please enable them to open this website
Day 10: Binary Numbers
You are viewing a single comment's thread. Return to all comments →
Hello everyone this is my solution in python3