mirror of
https://github.com/Fare-spec/cours.git
synced 2025-12-09 19:30:40 +00:00
formatte file
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from typing import Any
|
||||
|
||||
def partitionement(liste: list[Any],debut,fin):
|
||||
|
||||
def partitionement(liste: list[Any], debut, fin):
|
||||
pivot = liste[debut]
|
||||
gauche = debut + 1
|
||||
droite = fin - 1
|
||||
@@ -12,49 +13,16 @@ def partitionement(liste: list[Any],debut,fin):
|
||||
droite -= 1
|
||||
|
||||
if gauche < droite:
|
||||
exchange(liste,gauche,droite)
|
||||
exchange(liste, gauche, droite)
|
||||
gauche += 1
|
||||
droite -= 1
|
||||
exchange(liste,droite,debut)
|
||||
exchange(liste, droite, debut)
|
||||
return droite
|
||||
|
||||
|
||||
def exchange(liste, indx_g, indx_d):
|
||||
liste[indx_g],liste[indx_d] = liste[indx_d], liste[indx_g]
|
||||
|
||||
|
||||
l = [12,4,0,44,27]
|
||||
print(partitionement(l,0,len(l)-1))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
liste[indx_g], liste[indx_d] = liste[indx_d], liste[indx_g]
|
||||
|
||||
|
||||
l = [12, 4, 0, 44, 27]
|
||||
print(partitionement(l, 0, len(l) - 1))
|
||||
|
||||
Reference in New Issue
Block a user