mirror of
https://github.com/Fare-spec/cours.git
synced 2025-12-11 04:10:39 +00:00
first commit
This commit is contained in:
18
oracle/tri.py
Normal file
18
oracle/tri.py
Normal file
@@ -0,0 +1,18 @@
|
||||
def triage(liste:list) -> list:
|
||||
if len(liste) < 2:
|
||||
return list
|
||||
for i in range(len(liste)-1):
|
||||
if liste[i] > liste[i+1]:
|
||||
liste[i], liste[i+1] = liste[i+1], liste[i]
|
||||
return triage(liste)
|
||||
return liste
|
||||
|
||||
def triii(liste: list) -> list:
|
||||
if liste == [] :
|
||||
return []
|
||||
mini = 0
|
||||
for i in range(1, len(liste)):
|
||||
if liste[i] < liste[mini]:
|
||||
mini = i
|
||||
liste[0], liste[mini] = liste[mini], liste[0]
|
||||
return [liste[0]] + triii(liste[1:])
|
||||
Reference in New Issue
Block a user