Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def almostIncreasingSequence(sequence):
- count_numb = 0
- bRemove = False
- if sequence.index(max(sequence)) < sequence.index(min(sequence)):
- count_numb += 1
- sequence.remove(max(sequence))
- for idx in range(len(sequence)-1):
- if sequence[idx] >= sequence[idx+1]:
- to_remove = idx
- bRemove = True
- count_numb += 1
- # if bRemove : sequence.remove(sequence[to_remove])
- if bRemove and len(sequence)-1-to_remove >= 2 and sequence[to_remove] < sequence[to_remove+2] :
- sequence.pop(to_remove+1)
- elif bRemove and sequence[to_remove+1] <= min(sequence) :
- sequence.pop(to_remove+1)
- elif bRemove : sequence.remove(sequence[to_remove])
- for idx in range(len(sequence)-1):
- if sequence[idx] >= sequence[idx+1]:
- count_numb += 1
- if count_numb <=1 :
- result = True
- else:
- result = False
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement