diff --git a/.DS_Store b/.DS_Store index 38ad5b6c7137d54edc2b705a4fac73bf004a534a..2123ae47bd8ef83e1b398d97f7ec8e2ce611ea62 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Projet/.DS_Store b/Projet/.DS_Store index 3a2ffc2d18ce5b714e3d2e943b2a04fff657c174..012a194f43ef6645fe0c77bd378b13dfb3310c7b 100644 Binary files a/Projet/.DS_Store and b/Projet/.DS_Store differ diff --git a/Projet/README.md b/Projet/README.md index 0b833927a7d255076b1b54a2a06541c0444a9d34..dd22c9e95a1ce1b4950e5eda939a8805130ec462 100644 --- a/Projet/README.md +++ b/Projet/README.md @@ -4,5 +4,5 @@ author : Louis Chmielewski - - - # journal -- 6/03 : +- 11/03 : organisation de la résolution du projet diff --git a/Projet/src/bloc.py b/Projet/src/bloc.py index d58bde569598dd317d03f21a323988cb539d6a1c..ae3edca8ae3963771d17439f840c1335f58c0145 100755 --- a/Projet/src/bloc.py +++ b/Projet/src/bloc.py @@ -10,3 +10,42 @@ """ +from PIL import Image, ImageDraw + +class Bloc: + """Classe d'un bloc d'une image en pixel + """ + + def __init__(self, image: Image): + """ + $$$ + """ + self.image = image + + def __repr__(self) -> str: + """ + $$$ repr(DicoTrie([Association('a', 1)])) + "DicoTrie([Association('a', 1)])" + $$$ repr(DicoTrie([Association('a', 1), Association('b', 2)])) + "DicoTrie([Association('a', 1), Association('b', 2)])" + $$$ repr(DicoTrie([Association('c', 3), Association('a', 2), Association('b', 1)])) + "DicoTrie([Association('a', 2), Association('b', 1), Association('c', 3)])" + """ + return f"DicoTrie({repr(self.liste_assos)})" + + def __eq__(self, autre) -> bool: + """ + $$$ d1 = DicoTrie([Association("a", 1), Association("b", 2)]) + $$$ d2 = DicoTrie([Association("b", 2), Association("a", 1)]) + $$$ d3 = DicoTrie([Association("a", 1), Association("b", 2), Association("c", 3)]) + $$$ d1 == d2 + True + $$$ d1 == d3 + False + $$$ d1 == {"a": 1, "b": 2} + False + """ + if isinstance(autre, DicoTrie): + return self.liste_assos == autre.liste_assos + else: + return False \ No newline at end of file diff --git a/Tp01/.DS_Store b/Tp01/.DS_Store index 1ea4f8f77ec5d17550335a7756d70e129b54b52b..d2da421d72d10f2f3c6366735076c36fe4c04cf1 100644 Binary files a/Tp01/.DS_Store and b/Tp01/.DS_Store differ diff --git a/Tp05/.DS_Store b/Tp05/.DS_Store index 3e0563300041a8e1f12e167e8a09a7b9782e4e03..5b10303b2ee0c66a010d9c83b7955f08361dac24 100644 Binary files a/Tp05/.DS_Store and b/Tp05/.DS_Store differ diff --git a/Tp06/mesures.py b/Tp06/mesures.py index 5ab31e09851eaf707607abec471611c57506252c..6677b6be255d6a7323f78ca5000a7b4ae31a6b65 100755 --- a/Tp06/mesures.py +++ b/Tp06/mesures.py @@ -15,7 +15,7 @@ from association import Association from types import NoneType from timeit import timeit from random import randrange -#import matplotlib.pyplot as plt +import matplotlib.pyplot as plt def generation_dict(tailles: list[int]) -> list[dict[str, NoneType]]: """Renvoie une liste de dictionnaires dont les clés sont les diff --git a/Tp07/analyse_tris.csv b/Tp07/analyse_tris.csv new file mode 100644 index 0000000000000000000000000000000000000000..7526113c3f8b7814574ddf30e1f0af02fef32a18 --- /dev/null +++ b/Tp07/analyse_tris.csv @@ -0,0 +1,102 @@ +taille;"tri séléction";"tri insertion" + 0; 0.00; 0.00 + 1; 0.00; 0.00 + 2; 1.00; 1.00 + 3; 3.00; 2.62 + 4; 6.00; 4.96 + 5; 10.00; 7.72 + 6; 15.00; 11.44 + 7; 21.00; 15.40 + 8; 28.00; 19.02 + 9; 36.00; 24.62 + 10; 45.00; 28.80 + 11; 55.00; 35.70 + 12; 66.00; 40.96 + 13; 78.00; 50.26 + 14; 91.00; 56.38 + 15; 105.00; 66.54 + 16; 120.00; 73.34 + 17; 136.00; 81.82 + 18; 153.00; 94.12 + 19; 171.00; 103.36 + 20; 190.00; 109.78 + 21; 210.00; 121.60 + 22; 231.00; 131.76 + 23; 253.00; 143.06 + 24; 276.00; 156.52 + 25; 300.00; 175.36 + 26; 325.00; 182.90 + 27; 351.00; 192.02 + 28; 378.00; 212.32 + 29; 406.00; 227.84 + 30; 435.00; 243.40 + 31; 465.00; 262.58 + 32; 496.00; 278.14 + 33; 528.00; 293.86 + 34; 561.00; 312.92 + 35; 595.00; 332.28 + 36; 630.00; 344.32 + 37; 666.00; 354.34 + 38; 703.00; 397.18 + 39; 741.00; 410.56 + 40; 780.00; 429.42 + 41; 820.00; 453.40 + 42; 861.00; 461.80 + 43; 903.00; 485.46 + 44; 946.00; 517.10 + 45; 990.00; 540.00 + 46; 1035.00; 554.30 + 47; 1081.00; 575.34 + 48; 1128.00; 607.34 + 49; 1176.00; 620.18 + 50; 1225.00; 647.48 + 51; 1275.00; 693.96 + 52; 1326.00; 712.04 + 53; 1378.00; 732.64 + 54; 1431.00; 768.84 + 55; 1485.00; 794.12 + 56; 1540.00; 820.92 + 57; 1596.00; 822.34 + 58; 1653.00; 877.84 + 59; 1711.00; 917.66 + 60; 1770.00; 948.42 + 61; 1830.00; 956.04 + 62; 1891.00; 1005.00 + 63; 1953.00; 1042.60 + 64; 2016.00; 1037.82 + 65; 2080.00; 1087.02 + 66; 2145.00; 1147.22 + 67; 2211.00; 1184.68 + 68; 2278.00; 1215.44 + 69; 2346.00; 1239.10 + 70; 2415.00; 1247.28 + 71; 2485.00; 1310.14 + 72; 2556.00; 1336.78 + 73; 2628.00; 1395.50 + 74; 2701.00; 1417.10 + 75; 2775.00; 1464.58 + 76; 2850.00; 1482.62 + 77; 2926.00; 1545.84 + 78; 3003.00; 1566.48 + 79; 3081.00; 1622.52 + 80; 3160.00; 1637.64 + 81; 3240.00; 1686.34 + 82; 3321.00; 1740.88 + 83; 3403.00; 1789.50 + 84; 3486.00; 1814.38 + 85; 3570.00; 1857.88 + 86; 3655.00; 1929.30 + 87; 3741.00; 1980.88 + 88; 3828.00; 1973.52 + 89; 3916.00; 2066.94 + 90; 4005.00; 2085.78 + 91; 4095.00; 2125.72 + 92; 4186.00; 2220.08 + 93; 4278.00; 2240.44 + 94; 4371.00; 2283.70 + 95; 4465.00; 2359.88 + 96; 4560.00; 2385.16 + 97; 4656.00; 2450.00 + 98; 4753.00; 2473.96 + 99; 4851.00; 2531.32 +100; 4950.00; 2564.28 diff --git a/Tp07/analyse_tris.py b/Tp07/analyse_tris.py new file mode 100644 index 0000000000000000000000000000000000000000..9d12c3495eb527f26efa2ed40a25f584acada2ae --- /dev/null +++ b/Tp07/analyse_tris.py @@ -0,0 +1,79 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +""" +:mod:`analyse_tris` module +:author: FIL - Faculté des Sciences et Technologies - Univ. Lille <http://portail.fil.univ-lille1.fr>_ +:date: janvier 2017 +:dernières révisions: février 2018, février 2019 + +Analyse empirique des tris + +""" +from random import shuffle +from typing import Callable +from compare import compare +from ap_decorators import count +from tris import * + +################################################ +# ANALYSE EMPIRIQUE DES TRIS # +################################################ + +# ajout d'un compteur à la fonction compare +compare = count(compare) + +def analyser_tri(tri: Callable[[list[T], Callable[[T, T], int]], NoneType], + nbre_essais: int, + taille: int) -> float: + """ + renvoie: le nombre moyen de comparaisons effectuées par l'algo tri + pour trier des listes de taille t, la moyenne étant calculée + sur n listes aléatoires. + précondition: n > 0, t >= 0, la fonc + """ + res = 0 + for i in range(nbre_essais): + compare.counter = 0 + l = [k for k in range(taille)] + shuffle(l) + tri(l, compare) + res += compare.counter + return res / nbre_essais + + +if (__name__ == '__main__'): + from matplotlib import pyplot as plt + + # Calcul de nombres moyens de comparaison pour des listes + # de tailles comprises entre 0 et TAILLE_MAX + NB_ESSAIS = 50 + TAILLE_MAX = 100 + c_select = [0.0] * (TAILLE_MAX + 1) + c_insert = [0.0] * (TAILLE_MAX + 1) + + for t in range(TAILLE_MAX + 1): + c_select[t] = analyser_tri(tri_select, 1, t) + # inutile de moyenner pour le tri par sélection + c_insert[t] = analyser_tri(tri_insert, NB_ESSAIS, t) + + # Sauvegarde des données calculées dans un fichier au format CSV + prem_ligne = 'taille;"tri séléction";"tri insertion"\n' + ligne = '{:3d};{:8.2f};{:8.2f}\n' + with open('analyse_tris.csv', 'wt', encoding='utf8') as sortie: + sortie.write(prem_ligne) + for t in range(TAILLE_MAX + 1): + sortie.write(ligne.format(t, + c_select[t], + c_insert[t])) + + # Représentation graphique + plt.plot(list(range(TAILLE_MAX + 1)), c_select, 'b.', label='Tri sélection') + plt.plot(list(range(TAILLE_MAX + 1)), c_insert, 'r.', label='Tri insertion') + plt.title('Tris : nbre de comparaisons') + plt.legend() + plt.xlabel('n = taille des listes') + plt.ylabel('c(n) = nbre de comparaisons') + plt.savefig('tris_nbcomp.png') + plt.show() + diff --git a/Tp07/ap_decorators.py b/Tp07/ap_decorators.py new file mode 100644 index 0000000000000000000000000000000000000000..5f4adc9129d3d7ffef9d7dc68b59e4d6643d419d --- /dev/null +++ b/Tp07/ap_decorators.py @@ -0,0 +1,135 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +""" +:module: ap_decorators +:author: FIL - Faculté des Sciences et Technologies - Univ. Lille <http://portail.fil.univ-lille1.fr>_ +:date: 2018, september + +""" + +from functools import wraps + + +def trace(fct): + ''' + Decorator for tracing every call to fct. + Recursive calls are indented. + + :Example: + + >>> @trace + ... def fact(n): + ... if n == 0: + ... return 1 + ... else: + ... return n * fact(n - 1) + + >>> fact(5) + -> fact((5,), {}) + ... -> fact((4,), {}) + ...... -> fact((3,), {}) + ......... -> fact((2,), {}) + ............ -> fact((1,), {}) + ............... -> fact((0,), {}) + ............... <- 1 + ............ <- 1 + ......... <- 2 + ...... <- 6 + ... <- 24 + <- 120 + 120 + ''' + @wraps(fct) + def wrapper(*args, **kwargs): + dots = '...' * wrapper.__depth + print('{:s} -> {:s}{:s}'.format(dots, wrapper.__name__, repr((args, kwargs)))) + wrapper.__depth += 1 + y = fct(*args, **kwargs) + wrapper.__depth -= 1 + print('{:s} <- {:s}'.format(dots, repr(y))) + return y + wrapper.__depth = 0 + return wrapper + +def count(fct): + ''' + decorator for counting calls to function fct + + :Example: + + >>> @count + ... def fact(n): + ... if n == 0: + ... return 1 + ... else: + ... return n * fact(n - 1) + + >>> fact.counter + 0 + >>> fact(5) + 120 + >>> fact.counter + 6 + ''' + @wraps(fct) + def wrapper(*args, **kwargs): + y = fct(*args, **kwargs) + wrapper.counter += 1 + return y + wrapper.counter = 0 + return wrapper + + +def memoize(fct): + ''' + decorator for memoizing computed values of function fct + + :Example: + + >>> @count + ... @memoize + ... def fact(n): + ... if n == 0: + ... return 1 + ... else: + ... return n * fact(n - 1) + + >>> fact.counter + 0 + >>> fact(5) + 120 + >>> fact.counter + 6 + >>> fact.counter = 0 + >>> fact(5) + 120 + >>> fact.counter + 1 + ''' + cache = dict() + @wraps(fct) + def wrapper(*args, **kwargs): + key = repr((args, kwargs)) + if key in cache: + return cache[key] + else: + y = fct(*args, **kwargs) + cache[key] = y + return y + return wrapper + + + +if __name__ == '__main__': + import doctest + doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS, verbose=False) + + + + + + + + + diff --git a/Tp07/apl1test.py b/Tp07/apl1test.py new file mode 100644 index 0000000000000000000000000000000000000000..8533ccaca5d99e7cfb83d6d86aa9334bb6a73a40 --- /dev/null +++ b/Tp07/apl1test.py @@ -0,0 +1,89 @@ +import thonnycontrib +from thonnycontrib.backend.evaluator import Evaluator +import thonnycontrib.backend.l1test_backend +from thonny.plugins.cpython_backend.cp_back import MainCPythonBackend +import thonnycontrib.backend.doctest_parser +from thonnycontrib.backend.doctest_parser import ExampleWithExpected, ExampleWithoutExpected +import thonnycontrib.backend.ast_parser +from thonnycontrib.backend.ast_parser import L1DocTest +import thonnycontrib.backend.verdicts +from thonnycontrib.backend.verdicts.ExceptionVerdict import ExceptionVerdict + +import inspect +import tempfile +import os +import sys + +class MockBackend(MainCPythonBackend): + """ + Fake backend. + """ + def __init__(self): + ... + + def send_message(self, msg) -> None: + ... + +# register backend +thonnycontrib.backend.l1test_backend.BACKEND = MockBackend() + +def l1test_to_org(filename: str, source: str=""): + """ + Return an org abstract of the tests presents in `filename` file. + """ + abstract = {'total': 0, + 'success': 0, + 'failures': 0, + 'errors': 0, + 'empty': 0} + + if source == "": + with open(filename, 'rt') as fin: + source = fin.read() + evaluator = Evaluator(filename=filename, + source=source) + tests = evaluator.evaluate() + n = len(tests) + abstract['total'] = n + res = "" + for test in tests: + examples = test.get_examples() + res_examples = "" + nb_test, nb_test_ok = 0, 0 + empty = True + for example in examples: + verdict = test.get_verdict_from_example(example) + if isinstance(example, ExampleWithExpected): + nb_test += 1 + if verdict.isSuccess(): + nb_test_ok += 1 + abstract['success'] += 1 + else: + abstract['failures'] += 1 + empty = False + if isinstance(verdict, ExceptionVerdict): + abstract['errors'] += 1 + empty = False + res_examples += f"** {verdict}\n\n" + if not verdict.isSuccess(): + res_examples += f" {verdict.get_details()}\n\n" + if not empty: + res += f"* {test.get_name()} ~ {nb_test_ok}/{nb_test} réussis\n\n" + else: + abstract['empty'] += 1 + res += f"* {test.get_name()}\n\n Aucun test trouvé !\n\n" + res += res_examples + res = f"Tests exécutés : {abstract['total']}\nSuccès: {abstract['success']}, \ +Echecs: {abstract['failures']}, Erreurs: {abstract['errors']}, \ +Vide: {abstract['empty']}\n\n" + res + return res + + +def testmod(modulename: str): + """ + mimic the doctest.testmod function + for `modulename` module + """ + print(l1test_to_org(modulename)) + + diff --git a/Tp07/compare.py b/Tp07/compare.py new file mode 100644 index 0000000000000000000000000000000000000000..abad0a4c2af8427e32cf9f56cc7868fe742be0e1 --- /dev/null +++ b/Tp07/compare.py @@ -0,0 +1,44 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +""" +:mod:`compare` module +:author: FIL - FST - Univ. Lille <http://portail.fil.univ-lille1.fr>_ +:date: 2016, january +:dernière révision: février 2018 + +Fonction de comparaison +pour l'analyse des algos de recherche et de tri + +""" +from typing import TypeVar + + +T = TypeVar('T') +def compare(x: T, y: T) -> int: + """ + renvoie: + - -1 si x < y + - 0 si x == y + - 1 si x > y + précondition: x et y doivent être d'un type pour lequel les opérateurs de comparaison <, <=, == + peuvent s'appliquer + exemples: + + $$$ compare(1, 3) + -1 + $$$ compare(3, 1) + 1 + $$$ compare(3, 3) + 0 + """ + if x == y: + return 0 + elif x > y: + return 1 + else: + return -1 + +if (__name__ == '__main__'): + import apl1test + apl1test.testmod('compare.py') diff --git a/Tp07/tp_tri.py b/Tp07/tp_tri.py new file mode 100755 index 0000000000000000000000000000000000000000..bd3545d3d5980bdf3c6a8d539c8af49b4dd47863 --- /dev/null +++ b/Tp07/tp_tri.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +""" +:mod:`tris` module +:author: FIL - Faculté des Sciences et Technologies - + Univ. Lille <http://portail.fil.univ-lille1.fr>_ +:date: 2015, january +:dernière révision: mars 2024 + + +Tris de listes + +- tri par sélection +- tri par insertion + +""" + +from random import shuffle +import matplotlib.pyplot as plt + +def liste_alea(n:int) -> list[int]: + """ + Renvoie une liste de 0 à n-1 mélangé + Précondition : aucune + Exemple(s) : + $$$ + + """ + res = list(range(n)) + shuffle(res) + return res \ No newline at end of file diff --git a/Tp07/tris.py b/Tp07/tris.py new file mode 100644 index 0000000000000000000000000000000000000000..18df74065a465ff7025f8fc807a4bd08958869a5 --- /dev/null +++ b/Tp07/tris.py @@ -0,0 +1,193 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +""" +:mod:`tris` module +:author: FIL - Faculté des Sciences et Technologies - + Univ. Lille <http://portail.fil.univ-lille1.fr>_ +:date: 2015, january +:dernière révision: février 2018 + + +Tris de listes + +- tri par sélection +- tri par insertion + +""" + +from types import NoneType +from typing import Callable, TypeVar +from compare import compare +T = TypeVar('T') + +def est_trie(liste: list[T], comp: Callable[[T, T], int] = compare) -> bool: + """ + renvoir True si et seulement si liste est triée selon l'ordre défini par comp + + précondition: les éléments de liste doivent être comparables selon comp + + exemples: + + $$$ est_trie([1, 2, 3, 4]) + True + $$$ est_trie([1, 2, 4, 3]) + False + $$$ est_trie([]) + True + """ + i = 0 + res = True + while res and i < len(liste) - 1: + res = comp(liste[i], liste[i+1]) <= 0 + i += 1 + return res + # ou plus simplement + # return all(comp(liste[i], liste[i+1]) <= 0 for i in range(len(liste)-1)) + + +################################################ +# TRI PAR SELECTION # +################################################ + +def echanger(liste: list[T], i: int, j: int) -> NoneType: + """ + échange les éléments d'indice i et j de liste. + + précondition: 0 <= i,j < len(liste) + + exemples: + + $$$ l1 = [3, 1, 4, 9, 5, 1, 2] + $$$ l2 = l1.copy() + $$$ echanger(l2, 3, 5) + $$$ (l1[3], l1[5]) == (l2[5], l2[3]) + True + """ + liste[i], liste[j] = liste[j], liste[i] + + +def select_min(liste: list[T], a: int, b: int, comp: Callable[[T, T], int]=compare) -> int: + """ + renvoie l'indice du minimum dans la tranche liste[a:b] + précondition: 0 <= a < b <= long(liste), + éléments de liste comparables avec comp + exemples: + + $$$ select_min([1, 2, 3, 4, 5, 6, 7, 0], 0, 8) + 7 + $$$ select_min([1, 2, 3, 4, 5, 6, 7, 0], 1, 7) + 1 + """ + ind_min = a + # l'indice du plus petit élément de la tranche liste[a:a+1] est ind_min + for i in range(a + 1, b): + # supposons que l'indice du plus petit élément de la + # tranche liste[a:i] est ind_min + if comp(liste[i], liste[ind_min]) == -1: + ind_min = i + # alors l'indice du plus petit élément de la tranche liste[a:i+1] + # est ind_min + # à l'issue de l'itération l'indice du plus petit élément de la tranche + # liste[a:b] est ind_min + return ind_min + + +def tri_select(liste: list[T], comp: Callable[[T, T], int] = compare) -> NoneType: + """ + modifie la liste liste en triant ses éléments selon l'ordre défini par comp + Algorithme du tri par sélection du minimum + précondition: liste liste homogène d'éléments comparables selon comp + exemples: + + $$$ liste = [3, 1, 4, 1, 5, 9, 2] + $$$ tri_select(liste) + $$$ liste == [1, 1, 2, 3, 4, 5, 9] + True + $$$ from random import randrange + $$$ l1 = [randrange(1000) for k in range(randrange(100))] + $$$ l2 = l1.copy() + $$$ tri_select(l2) + $$$ est_trie(l2) + True + $$$ all(l1.count(elt) == l2.count(elt) for elt in l1) + True + $$$ all(l1.count(elt) == l2.count(elt) for elt in l2) + True + """ + n = len(liste) + # la tranche liste[0:1] est triée + for i in range(n - 1): + # supposons la tranche liste[0:i+1] triée + ind_min = select_min(liste, i, n, comp=comp) + echanger(liste, i, ind_min) + # alors la tranche liste[0:i+1] est triée + # à l'issue de l'itération la tranche liste[0:n] est triée + + +################################################ +# TRI PAR INSERTION # +################################################ + +def inserer(liste: list[T], i: int, comp: Callable[[T, T], int] = compare) -> NoneType: + """ + insère l'élément liste[i] à sa place dans la tranche + liste[0:i+1] de sorte que cette tranche soit triée + si liste[0:i] l'est auparavant + + précondition: 0 <= i < long(liste) + éléments de liste comparables par comp + exemples: + + $$$ liste = [1, 2, 4, 5, 3, 7, 6] + $$$ inserer(liste, 4) + $$$ liste == [1, 2, 3, 4, 5, 7, 6] + True + $$$ inserer(liste, 5) + $$$ liste == [1, 2, 3, 4, 5, 7, 6] + True + $$$ inserer(liste, 6) + $$$ liste == [1, 2, 3, 4, 5, 6, 7] + True + """ + aux = liste[i] + k = i + while k >= 1 and comp(aux, liste[k - 1]) == -1: + liste[k] = liste[k - 1] + k = k - 1 + liste[k] = aux + + +def tri_insert(liste: list[T], comp: Callable[[T, T], int] = compare) -> NoneType: + """ + modifie la liste liste en triant ses éléments selon l'ordre défini par comp Algorithme du tri par insertion + précondition: liste liste homogène d'éléments comparables selon comp + exemples: + + $$$ liste = [3, 1, 4, 1, 5, 9, 2] + $$$ tri_insert(liste) + $$$ liste == [1, 1, 2, 3, 4, 5, 9] + True + $$$ from random import randrange + $$$ l1 = [randrange(1000) for k in range(randrange(100))] + $$$ l2 = l1.copy() + $$$ tri_insert(l2) + $$$ est_trie(l2) + True + $$$ all(l1.count(elt) == l2.count(elt) for elt in l1) + True + $$$ all(l1.count(elt) == l2.count(elt) for elt in l2) + True + """ + n = len(liste) + # la tranche liste[0:1] est triée + for i in range(1, n): + # supposons la tranche liste[0:i] triée + inserer(liste, i, comp=comp) + # alors la tranche liste[0:i+1] est triée + # à l'issue de l'itération la tranche liste[0:n] est triée + + +if (__name__ == '__main__'): + import apl1test + apl1test.testmod('tris.py') diff --git a/Tp07/tris_nbcomp.png b/Tp07/tris_nbcomp.png new file mode 100644 index 0000000000000000000000000000000000000000..a2ce8bdaaad372e005af87d22e90db36c52fb421 Binary files /dev/null and b/Tp07/tris_nbcomp.png differ