Apr-24-2018, 07:17 PM
I don't know what the problem is, but the code definitely does not return the theoretical results for Pass 2. When creating code like this, you should try to estimate what the output should look like. Since you have theoretical answers, the expected values should be (for 1,000,000 iterations):
Using random numbers makes a solution more difficult, because the answer is different each time. I suggest you either use a fixed list for testing, or use a random number seed for testing purposes only. For example:
I suggest you proceed as follows with concentration on the Pass2 algorithm:
a. Use a preset list as suggested above.
b. Reduce the number of items in the array to 5 or 10.
c. Verify that Pass2 performs an accurate sort, by testing Pass2 by itself (print the list after each iteration).
d. When c. is successful, test with a 40 item list, then test with a random list.
If you need additional help, post the 'original question' in this thread.
Lewis
Pass1: 1 /930 = 107.5 (and my results were 1092 - which I consider an acceptable answer)
Pass2: 1/ 14880 = 1/16th of 1 /930 = 67.2 (and my results were 2079 = not acceptable)
Using random numbers makes a solution more difficult, because the answer is different each time. I suggest you either use a fixed list for testing, or use a random number seed for testing purposes only. For example:
random.seed(12345)For more information about Python random numbers see: https://python-forum.io/Thread-Proposed-...and-Python
I suggest you proceed as follows with concentration on the Pass2 algorithm:
a. Use a preset list as suggested above.
b. Reduce the number of items in the array to 5 or 10.
c. Verify that Pass2 performs an accurate sort, by testing Pass2 by itself (print the list after each iteration).
d. When c. is successful, test with a 40 item list, then test with a random list.
If you need additional help, post the 'original question' in this thread.
Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00