You are viewing a single comment's thread. Return to all comments →
import math import os import random import re import sys
if name == 'main': n = int(input().strip()) arr = []
while n > 0: arr.append(n % 2) n = n // 2 # print(arr) arr = arr[::-1] # print(arr) count = 0 max_count = 0 i = 0 while i < len(arr): if arr[i] == 0: if count > max_count: max_count = count count = 0 else: count += 1 if count > max_count: max_count = count i += 1 print(max_count)
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 →
!/bin/python3
import math import os import random import re import sys
if name == 'main': n = int(input().strip()) arr = []