We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 10: Binary Numbers
Day 10: Binary Numbers
Sort by
recency
|
2796 Discussions
|
Please Login in order to post a comment
!/bin/python3
import math import os import random import re import sys
if name == 'main': n = int(input().strip()) arr = []
My implementation:
`
if name == 'main': n = int(input().strip()) binary = bin(n)[2:].split('0') print(len(max(binary)))
`
import math import os import random import re import sys
if name == 'main': n = int(input().strip()) s = bin(n) # s.removeprefix('0b') arr = s[2:].split('0') max_length = max(len(x) for x in arr) print(max_length)