diff --git a/S2/TP4/tp4.py b/S2/TP4/tp4.py index 94bd870..e349a02 100644 --- a/S2/TP4/tp4.py +++ b/S2/TP4/tp4.py @@ -145,16 +145,14 @@ def tricho(l, a, b, x): while d < f: m1 = (d+f)//3 m2 = m1*2 - if l[m1] < x: + if l[m1] >= x: + f = m1 + elif l[m2] >= x: d = m1+1 f = m2 - elif l[m2] < x: - d = m2+1 else: - f = m1 + d = m2+1 est_dedans = x == l[d] return (est_dedans, d if x == l[d] else -1) - -print(dicho(LEXIQUE, 0, len(LEXIQUE), 'banane')) -print(tricho(LEXIQUE, 0, len(LEXIQUE), 'banane')) \ No newline at end of file +print(tricho(LEXIQUE_TRIE, 0, len(LEXIQUE_TRIE), 'banane')) \ No newline at end of file