• + 0 comments

    I started off using the built-in bin() function, but it felt like the point was to do it myself, so I made user_bin to replicate it.

    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    
    def user_bin(n):
        n = int(n)
        out = ""
        while(n > 0):
            remainder = n % 2
            n = n//2
            out += str(remainder)
        return out[::-1]
    
    if __name__ == '__main__':
        n = int(input().strip())
        print(max([len(i) for i in user_bin(n).split("0")]))