From ff8b4d6d50d887a32737142f7d02abd5d491bcce Mon Sep 17 00:00:00 2001 From: Spectre Date: Mon, 27 Jan 2025 09:51:56 +0100 Subject: [PATCH] Auto urgent commit. --- graphes/leaudibidon/Water_jug(en_xz).tar | Bin 0 -> 3408 bytes graphes/leaudibidon/Water_jug.py | 28 +++++++++++++++++++++++ graphes/monday_homework.py | 8 +++---- 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 graphes/leaudibidon/Water_jug(en_xz).tar diff --git a/graphes/leaudibidon/Water_jug(en_xz).tar b/graphes/leaudibidon/Water_jug(en_xz).tar new file mode 100644 index 0000000000000000000000000000000000000000..dae43c73371718f95516bd5295947ec5a7bad91c GIT binary patch literal 3408 zcmV-W4X^V3H+ooF000E$*0e?f03iVu0001VFXf})E&mM-T>vYXN`_~T#GB(Z*2pPI zu2IL?>9ZY2?g%NRG&~lSX3Bn1Zozgz)pCUU>HJZ$7m0nA7)J8LLZJ`ssj+lv+g{XC zmKNBa6Q=Ne;=5y??T))7^nky-AzJ?|rrc7LP(vHw+w>gaI>SU^{mE>e9`PUppoQV& z=}Mw!TV#k++n)KMf|bsY3^9#X+t+(SV1M-%@tt{+Bcb)v%hx#7YmB+>t=b|}GzKPI zDCr`}Gz08M(s3pi`$;u}i|%+T@{R^(FF>?}eS$5JE#a=eSaiOgHPD4;Z3&k&N4;v; z)&;ZkdhS)H0wm`fdq#_cG#ZPr)}uE#JEkN(XG`3lK$u=u-DG4SdB*Bm@u=20;y6)4 zR{ah~9bJ#p-9>*mAQH7U2XbRjo?IJVh&KuvY|)`uP~jmpbz;{+N#oS*8ja1)B6xYK1`Z4X!MAeI8fR(3FAr57cX7jAcop` zy4sZ$kX))LBT9FFNwK#ljuyazrCdEU<-+zN{;)BgPsqQDSm|3iDt`(int4>?96*^e zQcP;fGzi$t3CapX$mZxqcIW5z#+>&}*VN`o3r#URJ`BkD0`0$FVAWvX+Siw(CZ+KI zx8dMHRQI10P-f4V_%Gmy5)`OiOp3U)JNP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82sUDP{aXYt(MeXbaEy4X3hSfqw`~c^jGd(*0NA}a4Y!n}`nxp34FItb-o5qgyXI`%GI~EQ@67eE6G(%~i z8))R4z@|Sc$2w>rVRilWqL`fm2C@;XN^Gx#7+6Rftf zLqFXfqSK=Lz2#F2g7Gz>!s!rQV#-AJZDhk(RGdF?Fp=yopm}|T zG62D-Hk$U!=gyXWX)_g;?u?B5izU+xcWGwaGwVaCPyJpbglWLGulS+)L1j>mMW<2khT7@JLFig43 zlBbJ57tbMQZy{W65Ry@z+_ezfoCcF~l#Xt4?Wx0>bvN*d+W5;nXCDf_SVl?7#YoGJ zE&aaOzs>;=3Ls<~Jh<`>DsG*90%ck2_+1krUJ)F6Cpw)^$T_uX(KA^+NyGv}@Ck_@ zjC%|WURKFoMpkag8FZ{3p|op3P<6M`I?b9Irv*c5PLQU2bFS}m)oor9cIoy}p@Tk$ z%G*+2qOy<$)^|FP58BM%B4{qoNAl4)hF}gGJ~K+w{1e8rXAL4V6A2)uF7zkEBFwDQUYUzWAr$na?A z5;ZGNhUvSJRCPV9Kj1wdxA1Jv&NtD$+&=f;lz4? z#*|L{^KZ9DLCGdQ)YosTQ<^}V;Sn&tmp+Iapxc@=?%^Ic0U6MF5jJYKYOfJ*b))3~ m0001qL9dg++22P10jU~*TmS$!dg))W#Ao{g000001X)@@#Gx?& literal 0 HcmV?d00001 diff --git a/graphes/leaudibidon/Water_jug.py b/graphes/leaudibidon/Water_jug.py index 8398243..8911541 100644 --- a/graphes/leaudibidon/Water_jug.py +++ b/graphes/leaudibidon/Water_jug.py @@ -311,8 +311,36 @@ def main(): print(affichage_chemin(chemin)) print("--------------------------------------") +def question1(): + + print("Non pas tous les quantités de litres peuvent être représenter comme 6l.") +def question2(): + for i in range(10): + resolutions = atteindre(i,creer_water_jug(3,5),None, True) + for (sommet_final, nb_etapes, chemin) in resolutions: + print(f"sommet atteint: {sommet_final}, en {nb_etapes} etapes") + print(affichage_chemin(chemin)) + print("--------------------------------------") +def question3(): + solution = atteindre(4,creer_water_jug(3,5),None,True) + for (sommet_final, nb_etapes, chemin) in solution: + print(f"sommet atteint: {sommet_final}, en {nb_etapes} etapes") + print(affichage_chemin(chemin)) + print("--------------------------------------") + +def question4(): + solution = atteindre(1,creer_water_jug(3,5,9),None,True) + for (sommet_final, nb_etapes, chemin) in solution: + print(f"sommet atteint: {sommet_final}, en {nb_etapes} etapes") + print(affichage_chemin(chemin)) + print("--------------------------------------") + if __name__ == "__main__": import doctest doctest.testmod(verbose=True) main() + question1() + question2() + question3() + question4() diff --git a/graphes/monday_homework.py b/graphes/monday_homework.py index a890570..b50e4d4 100644 --- a/graphes/monday_homework.py +++ b/graphes/monday_homework.py @@ -1,13 +1,13 @@ def construire_bfs(graphe: dict, origine: str) -> dict: """ - Construit un arbre BFS (Breadth-First Search) à partir d'un graphe donné et d'un sommet d'origine. + Construit un arbre BFS à partir de graphe et d'un sommet d'origine. Args: graphe (dict): Un dictionnaire représentant le graphe, où les clés sont les sommets et les valeurs sont des listes de sommets adjacents. origine (str): Le sommet de départ pour la recherche en largeur. Returns: - dict: Un dictionnaire représentant l'arbre BFS, où les clés sont les sommets et les valeurs sont des tuples contenant la distance depuis l'origine et le parent du sommet dans l'arbre BFS. + dict: Un dictionnaire représentant l'arbre BFS, où les clés sont les sommets et les valeurs sont des tuples contenant la distance depuis l'origine et le sommet precédent. Examples: >>> graphe = { @@ -52,14 +52,14 @@ def construire_bfs(graphe: dict, origine: str) -> dict: def construire_dfs(graphe: dict, origine: str) -> dict: """ - Construit un arbre DFS (Depth-First Search) à partir d'un graphe donné et d'un sommet d'origine. + Construit un arbre DFS à partir de graphe et d'un sommet d'origine. Args: graphe (dict): Un dictionnaire représentant le graphe, où les clés sont les sommets et les valeurs sont des listes de sommets adjacents. origine (str): Le sommet de départ pour la recherche en profondeur. Returns: - dict: Un dictionnaire représentant l'arbre DFS, où les clés sont les sommets et les valeurs sont des tuples contenant la distance depuis l'origine et le parent du sommet dans l'arbre DFS. + dict: Un dictionnaire représentant l'arbre DFS. Examples: >>> graphe = {