Advertisement
alext6453

Untitled

Apr 6th, 2014
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. def subs(s):
  2.     for start in range(len(s)):
  3.         for end in range(start, (len(s))):
  4.             yield s[start:end]
  5.  
  6. def main():
  7.     tests = ['000', '1111', '001010101', '0001010101', '01010101',  '000000111010101', '0000001110101011', '00000011101010111111111111111']
  8.  
  9.     for b in tests:
  10.         most = max([item for item in subs(b) if item.count('1') == item.count('0')], key=len)
  11.         print(most)
  12.  
  13. if __name__ == '__main__':
  14.     main()
  15.     input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement