Skip to content

Instantly share code, notes, and snippets.

@dalejandroramirez
Created September 14, 2017 02:31
Show Gist options
  • Save dalejandroramirez/4a5eb35aedf3d879cce798c264a7345d to your computer and use it in GitHub Desktop.
Save dalejandroramirez/4a5eb35aedf3d879cce798c264a7345d to your computer and use it in GitHub Desktop.
dado un arreglo: determina si es posible volver ese arreglo estrictamente creciente quitando a lo sumo 1 numero
def almostIncreasingSequence(a):
def remov(a,i):
return a[:i]+ a[i+1:]
def creciente(a):
j=0
while j<len(a)-1 and a[j]<a[j+1]:
j=j+1
if j==len(a)-1:
return(True)
return (False)
i=0
if len(a)>=2:
if i<len(a)-1 and a[i]<a[i+1]:
while i<len(a)-1 and a[i]<a[i+1] :
i=i+1
if i==len(a)-1:
return(True)
print(True)
else:
b= remov(a,i)
c= remov(a,i+1)
if creciente(b)==True or creciente(c)==True:
return(True)
print(True)
else:
return(False)
print(False)
elif len(a)<2:
return(True)
print(True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment