Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. def almostIncreasingSequence(sequence):
  2.     count_numb = 0
  3.     bRemove = False
  4.    
  5.     if sequence.index(max(sequence)) < sequence.index(min(sequence)):
  6.         count_numb += 1
  7.         sequence.remove(max(sequence))
  8.  
  9.     for idx in range(len(sequence)-1):
  10.         if sequence[idx] >= sequence[idx+1]:
  11.             to_remove = idx
  12.             bRemove = True
  13.             count_numb += 1
  14.    
  15.    # if bRemove : sequence.remove(sequence[to_remove])
  16.        
  17.     if bRemove and len(sequence)-1-to_remove >= 2 and sequence[to_remove] < sequence[to_remove+2] :
  18.         sequence.pop(to_remove+1)
  19.     elif bRemove and sequence[to_remove+1] <= min(sequence) :
  20.         sequence.pop(to_remove+1)
  21.     elif bRemove : sequence.remove(sequence[to_remove])
  22.    
  23.  
  24.  
  25.     for idx in range(len(sequence)-1):
  26.         if sequence[idx] >= sequence[idx+1]:
  27.             count_numb += 1
  28.    
  29.     if count_numb <=1 :
  30.         result = True
  31.     else:
  32.         result = False
  33.            
  34.     return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement