Created
January 1, 2017 19:02
-
-
Save peroon/9f5487b062082fd6fb6e0edb0b83ae2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 二進数にする | |
| 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