Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def subs(s):
- for start in range(len(s)):
- for end in range(start, (len(s))):
- yield s[start:end]
- def main():
- tests = ['000', '1111', '001010101', '0001010101', '01010101', '000000111010101', '0000001110101011', '00000011101010111111111111111']
- for b in tests:
- most = max([item for item in subs(b) if item.count('1') == item.count('0')], key=len)
- print(most)
- if __name__ == '__main__':
- main()
- input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement