Python Day 10 : Binary Numbers | HackerRank 30 Days of Code Solutions


Task
Given a base- integer, , convert it to binary (base-). Then find and print the base- integer denoting the maximum number of consecutive 's in 's binary representation. When working with different bases, it is common to show the base as a subscript.

 Code:

import math
import os
import random
import re
import sys



if __name__ == '__main__':
    n = int(input())
    numbers = str(bin(n)[2:]).split('0')
    lenghts = [len(num) for num in numbers]
    print(max(lenghts))

AJ Blogs

Hello everyone, My name Arth and I like to write about what I learn. Follow My Website - https://sites.google.com/view/aj-blogs/home

Post a Comment

Previous Post Next Post
Best Programming Books

Facebook

AJ Facebook
Checkout Our Facebook Page
AJ Blogs
Checkout Our Instagram Page