Created
August 28, 2016 14:49
-
-
Save JenkinsDev/724a1b56d7be009f24283c78e9b4197a to your computer and use it in GitHub Desktop.
Finding All Possible Contiguous Sub Lists
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
def contiguous_sublists(vals): | |
sub_lists = [] | |
for ind, a in enumerate(vals): | |
sub_lists.append([a]) | |
for b in range(ind+1, len(vals)): | |
sub_lists.append(sub_lists[-1] + [vals[b]]) | |
return sub_lists |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment