From 0faf951d338ea650f323bfbca64aef6e3b5f50c4 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Tue, 24 Feb 2015 10:41:45 +0100 Subject: [PATCH 1/3] TP4 dicho --- S2/TP4/tp4.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/S2/TP4/tp4.py b/S2/TP4/tp4.py index 130d610..7e6082d 100644 --- a/S2/TP4/tp4.py +++ b/S2/TP4/tp4.py @@ -32,7 +32,20 @@ def seqTrie(l, a, b, x): # Jean-loup return None def dicho(l, a, b, x): # Geoffrey - return None + """ + list, int, int, a → (bool, int) + Renvoie la position d'un élément x dans la liste l + aux bornes a et b par dichotomie. + """ + a = d + f = b - 1 + while d < f: + m = (d+f)//2 + if l[m] < x: + d = m+1 + else: + f = m + return x == l[d] question(2) # Utiliser LEXIQUE From d1818df1fded4a007da582e4a8480842fbba168c Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Tue, 24 Feb 2015 10:42:21 +0100 Subject: [PATCH 2/3] TP4 gitignore --- S2/TP4/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 S2/TP4/.gitignore diff --git a/S2/TP4/.gitignore b/S2/TP4/.gitignore new file mode 100644 index 0000000..4d68079 --- /dev/null +++ b/S2/TP4/.gitignore @@ -0,0 +1,2 @@ +lexique* +anagrammes.txt \ No newline at end of file From dee1ef05145a45d6c139214a3190ba73e1a69585 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Tue, 24 Feb 2015 10:43:27 +0100 Subject: [PATCH 3/3] TP4 Import lexique --- S2/TP4/tp4.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/S2/TP4/tp4.py b/S2/TP4/tp4.py index 7e6082d..eb4b396 100644 --- a/S2/TP4/tp4.py +++ b/S2/TP4/tp4.py @@ -49,6 +49,8 @@ def dicho(l, a, b, x): # Geoffrey question(2) # Utiliser LEXIQUE +from lexique import * + squestion('a') # Vérifier que LEXIQUE est triée squestion('b') # Effectuer de nombreuses recherches de LEXIQUE