Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (27 sloc) 589 Bytes
def find_seq(lists):
"""Given a random list of number this function will extract all the sequences
and return a list of sequences present in the list"""
a=[]
list_of_seq=[]
j=0
i=0
while lists:
j=i+1
try:
while lists[j]-lists[i]==1:
if lists[i] not in list_of_seq:
list_of_seq.append(lists[i])
if lists[j] not in list_of_seq:
list_of_seq.append(lists[j])
i=0
j=i+1
lists.pop(0)
except IndexError:
a.append(list_of_seq)
list_of_seq=[]
if len(list_of_seq)>0:
a.append(list_of_seq)
list_of_seq=[]
lists.pop(0)
i=0
return a