import random

"""
Explanation: Assignment 1

Implement the sorting algorithm you came up with in pseudocode with Python.
Test the sorting algorithm with a list of 10, 100, 1000 random numbers and compare the result using the %time to time your code and submit your results in code comments.
End of explanation
"""


def ownsort(int_list):
    for i in range(len(int_list) - 1):
        k = i
        for j in range(i + 1, len(int_list)):
            if int_list[j] < int_list[k]:
                k = j
        int_list[i], int_list[k] = int_list[k], int_list[i]
    return int_list

int_list = [3,1,6,55,13,22,6,9,32]
ownsort(int_list)

"""
Explanation: Pseudocode
Read in the list and count the number of its elements. Build a loop that runs as many times. 
Build a second loop, starting at the index of the first element plus 1, runing for the full length of the list.
Check if the selected element is smaller than the one from the first loop. If it is: Exchange the two elements.
The algorithm
End of explanation
"""


# Generate random numbers

int_list_10 = []
for i in range(0,10):
    int_list_10.append(random.randint(1,1000))

int_list_100 = []
for i in range(0,100):
    int_list_100.append(random.randint(1,1000))

int_list_1000 = []
for i in range(0,1000):
    int_list_1000.append(random.randint(1,1000))

print(ownsort(int_list_10))
%time

"""
Explanation: Test the sorting Algorithm
End of explanation
"""


print(ownsort(int_list_100))
%time

"""
Explanation: Result of %time:
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
Wall time: 5.72 µs
End of explanation
"""


print(ownsort(int_list_1000))
%time

"""
Explanation: Result of %time:
CPU times: user 0 ns, sys: 0 ns, total: 0 ns
Wall time: 5.48 µs
End of explanation
"""


