You are viewing a single comment's thread. Return to all 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")]))
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 →
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.