May-11-2018, 03:18 PM
there are number of problems in your code.
1. in your code, i is the item in the list positions (line 11). At the same time, in the following code you treat it as index. I would assume it's not what you want. So you check that positions[i-1] == 0 (that is positions[-1]==0) and want to check that A[i] > B[i] > C[i] > D[i] or that A[i] < B[i] < C[i] < D[i] in order to append -1. however A[0] == B[0] == C[0] == D[0] == 1 and you don't add anything. so it exits the loop because there are no more values to iterate over
1. in your code, i is the item in the list positions (line 11). At the same time, in the following code you treat it as index. I would assume it's not what you want. So you check that positions[i-1] == 0 (that is positions[-1]==0) and want to check that A[i] > B[i] > C[i] > D[i] or that A[i] < B[i] < C[i] < D[i] in order to append -1. however A[0] == B[0] == C[0] == D[0] == 1 and you don't add anything. so it exits the loop because there are no more values to iterate over
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs