Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • master
1 result

Target

Select target project
No results found
Select Git revision
  • tgicquel-master-patch-00157
  • master
2 results
Show changes

Commits on Source 34

55 files
+ 342062
117
Compare changes
  • Side-by-side
  • Inline

Files

+1362 −0

File added.

Preview size limit exceeded, changes collapsed.

TD02/code/Pile.py

deleted100644 → 0
+0 −20
Original line number Diff line number Diff line
class Pile():
    def __init__(self, values = []):
        self.__values = []
        for v in values:
            self.ajoute(v)

    def ajoute(self, v):
        self.__values.append(v)
        return v

    def supprime(self):
        v = self.__values.pop()
        return v

    def affiche(self):
        for v in self.__values:
            print(v)

    def taille(self): 
        return len(self.__values)
 No newline at end of file

TD02/code/load.py

deleted100644 → 0
+0 −12
Original line number Diff line number Diff line
data = []

with open("etudiants.txt") as f:
    keys = None
    for line in f:
        l = [w.strip() for w in line.split(';')]
        if keys is None:
            keys = l
        else:
            data.append({k:v for k, v in zip(keys, l)})

print(data)
 No newline at end of file

TD02/code/selection.py

deleted100644 → 0
+0 −20
Original line number Diff line number Diff line
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]))
 No newline at end of file

TD02/code/test_analyse_simple.py

deleted100644 → 0
+0 −37
Original line number Diff line number Diff line
import time
import random
import matplotlib.pyplot as plt

nvalues = [100, 500, 1500, 2000, 2500, 3000]

timesSorted = []
timesSort = []

for i in nvalues:

    random.seed()
    p = 12**2
    liste = []
    
    for x in range(i): liste.append(random.randint(0, p))

    c = liste.copy()
    a=time.perf_counter()
    triSorted = sorted(c)
    b=time.perf_counter()
    timesSorted.append(b-a)

    c = liste.copy()
    a=time.perf_counter()
    triSort = c
    triSort.sort()
    b=time.perf_counter()
    timesSort.append(b-a)

plt.plot(nvalues, timesSorted, "g-", label="Tri 1")
plt.plot(nvalues, timesSort, "b-", label="Tri 2")
plt.xlabel("Taille du jeu de données")
plt.ylabel("Temps")
plt.legend(loc="upper left")
plt.title("Comparaison des performances des algorithmes de tri")
plt.show()
 No newline at end of file

TD02/code/test_heap.py

deleted100644 → 0
+0 −9
Original line number Diff line number Diff line
import heapq
tas = []

for i in range(5): heapq.heappush(tas, i)

while not len(tas) == 0: 
  print(heapq.heappop(tas), end=" ")

# 0 1 2 3 4
 No newline at end of file

TD02/code/test_lifoqueue.py

deleted100644 → 0
+0 −9
Original line number Diff line number Diff line
import queue
pile = queue.LifoQueue()

for i in range(5): pile.put(i)

while not pile.empty(): 
  print(pile.get(), end=" ")

# 4 3 2 1 0
 No newline at end of file

TD02/code/test_pile.py

deleted100644 → 0
+0 −9
Original line number Diff line number Diff line
from pile import *

p = Pile()

for d in data:
  p.ajoute(d) 
  e = p.supprime()
    
print(e['nom'] + " " + e['prenom']) # Arthaud Nathalie
 No newline at end of file
Original line number Diff line number Diff line
nom;prenom;filiere;note;absences
Dupond;Pierre;MP;19;7
Dupond;Jeanne;MP;19;5
Dupont;Jeanne;MP;19;5
Clavier;Christian;PSI;14;1
Gilles;Eric;PC;16;3
Arthaud;Nathalie;MP;15;0
 No newline at end of file
+896 −0

File added.

Preview size limit exceeded, changes collapsed.

+1025 −0

File added.

Preview size limit exceeded, changes collapsed.