This commit is contained in:
Mari Wahl 2015-01-10 01:09:23 -05:00
parent bc442a0727
commit c3cb3f1c1b
2 changed files with 34 additions and 25 deletions
src/builtin_structures

View file

@ -11,20 +11,22 @@ def find_long_con_inc(seq):
[-2, 3, 5]
>>> find_long_con_inc([1, 3, -2, 3, 5, 6])
[-2, 3, 5, 6]
>>> find_long_con_inc([1, 3, 4, -13, 2, 5, 8, -1, 2,-17])
[-13, 2, 5, 8]
'''
aux = []
result = []
res, aux = [], []
seq.append(-float('infinity'))
for i, pivot in enumerate(seq[:-1]):
aux.append(pivot)
if pivot > seq[i+1]:
if len(aux) > len(result):
result = aux
for i, n in enumerate(seq[:-1]):
aux.append(n)
if n > seq[i+1]:
if len(res) < len(aux):
res = aux[:]
aux = []
return result
return res
if __name__ == '__main__':