Tri sélectif
This chall requires us to sort an array. But we don’t see the array (can’t know every values). We only can check two values to know which one is the greater, change the position of two values and finally, check if the array is sorted.
For that I used a basic selection sort algorithm:
1
2
3
4
5
6
7
8
def trier(N):
for i in range(N):
min_index = i
for j in range(i + 1, N):
if comparer(j,min_index) == 1:
min_index = j
if min_index != i:
echanger(i, min_index)
We only had to complete the function in the client.py
file given and run it: