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
|
2792 Discussions
|
Please Login in order to post a comment
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)
In C language,
PYTHON 3 CODE
I wanted to challenge myself a little bit more and decided to create a function that convert decimal to binary instead of using the bin() one.
javascript solution