Skip to content
Snippets Groups Projects
Select Git revision
  • e5b01982650b55893e5009fb4834cc0ec6545db9
  • master default protected
2 results

test_analyse_simple.py

Blame
  • Forked from Vuillemot Romain / INF-TC1
    Source project has a limited visibility.
    selection.py 546 B
    def selectionSort(l: list = []) -> list:
        """Tri par selection en ligne"""
        for i in range(0, len(l)):
            min = i
            for j in range(i+1, len(l)):
                if(l[j] < l[min]):
                    min = j
            tmp = l[i]
            l[i] = l[min]
            l[min] = tmp
        
        return l  
    
    if __name__=="__main__": 
        liste = [54,26,93,17,77,31,44,55,20]
        
        assert(sorted(liste) == selectionSort(liste.copy()))
        assert([] == selectionSort([]))
        assert([1] == selectionSort([1]))
        assert([1, 1] == selectionSort([1, 1]))