You are viewing a single comment's thread. Return to all comments →
Also, you can use len() to count ones. Since we are sure that the string only consists of ones, we can count it’s length, because it’s more generic.
print len(max(bin(int(raw_input())).strip('0b').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 →
Also, you can use len() to count ones. Since we are sure that the string only consists of ones, we can count it’s length, because it’s more generic.
print len(max(bin(int(raw_input())).strip('0b').split('0')))