Skip to content

Instantly share code, notes, and snippets.

@peroon
Created January 1, 2017 19:02
Show Gist options
  • Select an option

  • Save peroon/9f5487b062082fd6fb6e0edb0b83ae2c to your computer and use it in GitHub Desktop.

Select an option

Save peroon/9f5487b062082fd6fb6e0edb0b83ae2c to your computer and use it in GitHub Desktop.
# 二進数にする
n = 15
binary_s = format(n, 'b')
binary_s = "11000001111010"
print binary_s
print len(binary_s)
from itertools import groupby
def count_continuous(s):
len_list = []
for key, group in groupby(s):
len_list.append(len(list(group)))
return max(len_list)
print count_continuous(binary_s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment