Skip to content

Instantly share code, notes, and snippets.

@JenkinsDev
Created August 28, 2016 14:49
Show Gist options
  • Save JenkinsDev/724a1b56d7be009f24283c78e9b4197a to your computer and use it in GitHub Desktop.
Save JenkinsDev/724a1b56d7be009f24283c78e9b4197a to your computer and use it in GitHub Desktop.
Finding All Possible Contiguous Sub Lists
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