1

I'm trying to relax on CodeSignal but i got this

"Traceback (most recent call last):
  main.py3
 in the pre-written template, in getUserOutputs
    userOutput = _runjpmds(testInputs[i])
  main.py3
 in the pre-written template, in _runjpmds
    return almostIncreasingSequence(*_fArgs_fnlehdkfpkip)
  main.py3
 on line 13, in almostIncreasingSequence
    del(newarr[i])
IndexError: list assignment index out of range

But why?

def ifgood(arr):
for i in range(0, len(arr)-1):
    if arr[i+1] - arr[i] <= 0:
        return False
return True

def almostIncreasingSequence(sequence):
    if len(sequence) == 1:
        return True
    for i in range(0, len(sequence)):
        newarr = sequence
        del(newarr[i])
        if ifgood(newarr) == True:
            return True
    return False
Cohan
  • 4,384
  • 2
  • 22
  • 40
Paweł Długosz
  • 129
  • 2
  • 9

0 Answers0