Skip to content
Snippets Groups Projects
Commit 5dbc3e35 authored by Romain Vuillemot's avatar Romain Vuillemot
Browse files

Formattage code exemples

parent f4152d9a
Branches
No related tags found
No related merge requests found
# TODO: comparaison de différents tris
\ No newline at end of file
def selectionSort(alist):
for l in range(len(alist )-1,0,-1):
positionOfMax =0
for location in range (1, l+1):
if alist[location]>alist[ positionOfMax ]:
positionOfMax = location
temp = alist[l]
alist[l] = alist[positionOfMax]
alist[positionOfMax] = temp
alist = [54 ,26 ,93 ,17 ,77 ,31 ,44 ,55 ,20]
selectionSort(alist)
print(alist)
\ No newline at end of file
def algo(words):
t = []
for word in words:
t.append((len(word), word))
t.sort(key=lambda t: t[1][-1])
res = []
for l, w in t:
res.append(w)
res = filter(lambda t: 'a' in t, res)
return list(res)
print(algo(["Pierre", "Jean", "Marie", "Eric", "Nathalie", "Yvonne"]))
\ No newline at end of file
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment