diff --git a/PreStSauveur/2nd/Algo/Tri/B_2nd_2.pdf b/PreStSauveur/2nd/Algo/Tri/B_2nd_2.pdf new file mode 100644 index 0000000..9016833 Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/B_2nd_2.pdf differ diff --git a/PreStSauveur/2nd/Algo/Tri/B_2nd_2.tex b/PreStSauveur/2nd/Algo/Tri/B_2nd_2.tex new file mode 100755 index 0000000..76bd70e --- /dev/null +++ b/PreStSauveur/2nd/Algo/Tri/B_2nd_2.tex @@ -0,0 +1,97 @@ +\documentclass[a4paper,10pt, landscape]{classCours} +\usepackage{listings} + +\definecolor{darkWhite}{rgb}{0.94,0.94,0.94} + +\lstset{ + aboveskip=1mm, + belowskip=-1mm, + backgroundcolor=\color{darkWhite}, + basicstyle=\footnotesize, + breakatwhitespace=false, + breaklines=true, + captionpos=b, + commentstyle=\color{red}, + deletekeywords={...}, + escapeinside={\%*}{*)}, + extendedchars=true, + framexleftmargin=16pt, + framextopmargin=3pt, + framexbottommargin=3pt, + frame=tb, + keepspaces=true, + keywordstyle=\color{blue}, + language=Python, + literate= + {²}{{\textsuperscript{2}}}1 + {⁴}{{\textsuperscript{4}}}1 + {⁶}{{\textsuperscript{6}}}1 + {⁸}{{\textsuperscript{8}}}1 + {€}{{\euro{}}}1 + {é}{{\'e}}1 + {è}{{\`{e}}}1 + {ê}{{\^{e}}}1 + {ë}{{\¨{e}}}1 + {É}{{\'{E}}}1 + {Ê}{{\^{E}}}1 + {û}{{\^{u}}}1 + {ù}{{\`{u}}}1 + {â}{{\^{a}}}1 + {à}{{\`{a}}}1 + {á}{{\'{a}}}1 + {ã}{{\~{a}}}1 + {Á}{{\'{A}}}1 + {Â}{{\^{A}}}1 + {Ã}{{\~{A}}}1 + {ç}{{\c{c}}}1 + {Ç}{{\c{C}}}1 + {õ}{{\~{o}}}1 + {ó}{{\'{o}}}1 + {ô}{{\^{o}}}1 + {Õ}{{\~{O}}}1 + {Ó}{{\'{O}}}1 + {Ô}{{\^{O}}}1 + {î}{{\^{i}}}1 + {Î}{{\^{I}}}1 + {í}{{\'{i}}}1 + {Í}{{\~{Í}}}1, + morekeywords={*,...}, + numbers=left, + numbersep=10pt, + numberstyle=\tiny\color{black}, + rulecolor=\color{black}, + showspaces=false, + showstringspaces=false, + showtabs=false, + stepnumber=1, + stringstyle=\color{gray}, + tabsize=4, + title=\lstname, +} + +\pagestyle{empty} +\geometry{left=10mm,right=10mm, top=7mm, bottom=7mm} + +\author{} +\title{} +\date{} + +\begin{document} + +\begin{minipage}{0.4\textwidth} + \lstinputlisting[language=Python]{tri_bulles.py} +\end{minipage} +\hfill +\begin{minipage}{0.55\textwidth} + \includegraphics[height=250pt, width=430pt, keepaspectratio]{./fig/2nd2_bulles} +\end{minipage} + +\begin{minipage}{0.4\textwidth} + \lstinputlisting[language=Python]{tri_min.py} +\end{minipage} +\hfill +\begin{minipage}{0.55\textwidth} + \includegraphics[height=280pt, width=430pt, keepaspectratio]{./fig/2nd2_min} +\end{minipage} + +\end{document} diff --git a/PreStSauveur/2nd/Algo/Tri/B_2nd_3.pdf b/PreStSauveur/2nd/Algo/Tri/B_2nd_3.pdf new file mode 100644 index 0000000..9ee202e Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/B_2nd_3.pdf differ diff --git a/PreStSauveur/2nd/Algo/Tri/B_2nd_3.tex b/PreStSauveur/2nd/Algo/Tri/B_2nd_3.tex new file mode 100755 index 0000000..23aa9f8 --- /dev/null +++ b/PreStSauveur/2nd/Algo/Tri/B_2nd_3.tex @@ -0,0 +1,97 @@ +\documentclass[a4paper,10pt, landscape]{classCours} +\usepackage{listings} + +\definecolor{darkWhite}{rgb}{0.94,0.94,0.94} + +\lstset{ + aboveskip=1mm, + belowskip=-1mm, + backgroundcolor=\color{darkWhite}, + basicstyle=\footnotesize, + breakatwhitespace=false, + breaklines=true, + captionpos=b, + commentstyle=\color{red}, + deletekeywords={...}, + escapeinside={\%*}{*)}, + extendedchars=true, + framexleftmargin=16pt, + framextopmargin=3pt, + framexbottommargin=3pt, + frame=tb, + keepspaces=true, + keywordstyle=\color{blue}, + language=Python, + literate= + {²}{{\textsuperscript{2}}}1 + {⁴}{{\textsuperscript{4}}}1 + {⁶}{{\textsuperscript{6}}}1 + {⁸}{{\textsuperscript{8}}}1 + {€}{{\euro{}}}1 + {é}{{\'e}}1 + {è}{{\`{e}}}1 + {ê}{{\^{e}}}1 + {ë}{{\¨{e}}}1 + {É}{{\'{E}}}1 + {Ê}{{\^{E}}}1 + {û}{{\^{u}}}1 + {ù}{{\`{u}}}1 + {â}{{\^{a}}}1 + {à}{{\`{a}}}1 + {á}{{\'{a}}}1 + {ã}{{\~{a}}}1 + {Á}{{\'{A}}}1 + {Â}{{\^{A}}}1 + {Ã}{{\~{A}}}1 + {ç}{{\c{c}}}1 + {Ç}{{\c{C}}}1 + {õ}{{\~{o}}}1 + {ó}{{\'{o}}}1 + {ô}{{\^{o}}}1 + {Õ}{{\~{O}}}1 + {Ó}{{\'{O}}}1 + {Ô}{{\^{O}}}1 + {î}{{\^{i}}}1 + {Î}{{\^{I}}}1 + {í}{{\'{i}}}1 + {Í}{{\~{Í}}}1, + morekeywords={*,...}, + numbers=left, + numbersep=10pt, + numberstyle=\tiny\color{black}, + rulecolor=\color{black}, + showspaces=false, + showstringspaces=false, + showtabs=false, + stepnumber=1, + stringstyle=\color{gray}, + tabsize=4, + title=\lstname, +} + +\pagestyle{empty} +\geometry{left=10mm,right=10mm, top=7mm, bottom=7mm} + +\author{} +\title{} +\date{} + +\begin{document} + +\begin{minipage}{0.4\textwidth} + \lstinputlisting[language=Python]{tri_bulles.py} +\end{minipage} +\hfill +\begin{minipage}{0.55\textwidth} + \includegraphics[height=250pt, width=430pt, keepaspectratio]{./fig/2nd3_bulles} +\end{minipage} + +\begin{minipage}{0.4\textwidth} + \lstinputlisting[language=Python]{tri_min.py} +\end{minipage} +\hfill +\begin{minipage}{0.55\textwidth} + \includegraphics[height=280pt, width=430pt, keepaspectratio]{./fig/2nd3_min} +\end{minipage} + +\end{document} diff --git a/PreStSauveur/2nd/Algo/Tri/B_2nd_4.pdf b/PreStSauveur/2nd/Algo/Tri/B_2nd_4.pdf new file mode 100644 index 0000000..1fdb022 Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/B_2nd_4.pdf differ diff --git a/PreStSauveur/2nd/Algo/Tri/B_2nd_4.tex b/PreStSauveur/2nd/Algo/Tri/B_2nd_4.tex new file mode 100755 index 0000000..3f45f6d --- /dev/null +++ b/PreStSauveur/2nd/Algo/Tri/B_2nd_4.tex @@ -0,0 +1,97 @@ +\documentclass[a4paper,10pt, landscape]{classCours} +\usepackage{listings} + +\definecolor{darkWhite}{rgb}{0.94,0.94,0.94} + +\lstset{ + aboveskip=1mm, + belowskip=-1mm, + backgroundcolor=\color{darkWhite}, + basicstyle=\footnotesize, + breakatwhitespace=false, + breaklines=true, + captionpos=b, + commentstyle=\color{red}, + deletekeywords={...}, + escapeinside={\%*}{*)}, + extendedchars=true, + framexleftmargin=16pt, + framextopmargin=3pt, + framexbottommargin=3pt, + frame=tb, + keepspaces=true, + keywordstyle=\color{blue}, + language=Python, + literate= + {²}{{\textsuperscript{2}}}1 + {⁴}{{\textsuperscript{4}}}1 + {⁶}{{\textsuperscript{6}}}1 + {⁸}{{\textsuperscript{8}}}1 + {€}{{\euro{}}}1 + {é}{{\'e}}1 + {è}{{\`{e}}}1 + {ê}{{\^{e}}}1 + {ë}{{\¨{e}}}1 + {É}{{\'{E}}}1 + {Ê}{{\^{E}}}1 + {û}{{\^{u}}}1 + {ù}{{\`{u}}}1 + {â}{{\^{a}}}1 + {à}{{\`{a}}}1 + {á}{{\'{a}}}1 + {ã}{{\~{a}}}1 + {Á}{{\'{A}}}1 + {Â}{{\^{A}}}1 + {Ã}{{\~{A}}}1 + {ç}{{\c{c}}}1 + {Ç}{{\c{C}}}1 + {õ}{{\~{o}}}1 + {ó}{{\'{o}}}1 + {ô}{{\^{o}}}1 + {Õ}{{\~{O}}}1 + {Ó}{{\'{O}}}1 + {Ô}{{\^{O}}}1 + {î}{{\^{i}}}1 + {Î}{{\^{I}}}1 + {í}{{\'{i}}}1 + {Í}{{\~{Í}}}1, + morekeywords={*,...}, + numbers=left, + numbersep=10pt, + numberstyle=\tiny\color{black}, + rulecolor=\color{black}, + showspaces=false, + showstringspaces=false, + showtabs=false, + stepnumber=1, + stringstyle=\color{gray}, + tabsize=4, + title=\lstname, +} + +\pagestyle{empty} +\geometry{left=10mm,right=10mm, top=7mm, bottom=7mm} + +\author{} +\title{} +\date{} + +\begin{document} + +\begin{minipage}{0.4\textwidth} + \lstinputlisting[language=Python]{tri_bulles.py} +\end{minipage} +\hfill +\begin{minipage}{0.55\textwidth} + \includegraphics[height=250pt, width=430pt, keepaspectratio]{./fig/2nd4_bulles} +\end{minipage} + +\begin{minipage}{0.4\textwidth} + \lstinputlisting[language=Python]{tri_min.py} +\end{minipage} +\hfill +\begin{minipage}{0.55\textwidth} + \includegraphics[height=280pt, width=430pt, keepaspectratio]{./fig/2nd4_min} +\end{minipage} + +\end{document} diff --git a/PreStSauveur/2nd/Algo/Tri/B_2nd_6.pdf b/PreStSauveur/2nd/Algo/Tri/B_2nd_6.pdf new file mode 100644 index 0000000..273ab4c Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/B_2nd_6.pdf differ diff --git a/PreStSauveur/2nd/Algo/Tri/B_2nd_6.tex b/PreStSauveur/2nd/Algo/Tri/B_2nd_6.tex new file mode 100755 index 0000000..2960f99 --- /dev/null +++ b/PreStSauveur/2nd/Algo/Tri/B_2nd_6.tex @@ -0,0 +1,97 @@ +\documentclass[a4paper,10pt, landscape]{classCours} +\usepackage{listings} + +\definecolor{darkWhite}{rgb}{0.94,0.94,0.94} + +\lstset{ + aboveskip=1mm, + belowskip=-1mm, + backgroundcolor=\color{darkWhite}, + basicstyle=\footnotesize, + breakatwhitespace=false, + breaklines=true, + captionpos=b, + commentstyle=\color{red}, + deletekeywords={...}, + escapeinside={\%*}{*)}, + extendedchars=true, + framexleftmargin=16pt, + framextopmargin=3pt, + framexbottommargin=3pt, + frame=tb, + keepspaces=true, + keywordstyle=\color{blue}, + language=Python, + literate= + {²}{{\textsuperscript{2}}}1 + {⁴}{{\textsuperscript{4}}}1 + {⁶}{{\textsuperscript{6}}}1 + {⁸}{{\textsuperscript{8}}}1 + {€}{{\euro{}}}1 + {é}{{\'e}}1 + {è}{{\`{e}}}1 + {ê}{{\^{e}}}1 + {ë}{{\¨{e}}}1 + {É}{{\'{E}}}1 + {Ê}{{\^{E}}}1 + {û}{{\^{u}}}1 + {ù}{{\`{u}}}1 + {â}{{\^{a}}}1 + {à}{{\`{a}}}1 + {á}{{\'{a}}}1 + {ã}{{\~{a}}}1 + {Á}{{\'{A}}}1 + {Â}{{\^{A}}}1 + {Ã}{{\~{A}}}1 + {ç}{{\c{c}}}1 + {Ç}{{\c{C}}}1 + {õ}{{\~{o}}}1 + {ó}{{\'{o}}}1 + {ô}{{\^{o}}}1 + {Õ}{{\~{O}}}1 + {Ó}{{\'{O}}}1 + {Ô}{{\^{O}}}1 + {î}{{\^{i}}}1 + {Î}{{\^{I}}}1 + {í}{{\'{i}}}1 + {Í}{{\~{Í}}}1, + morekeywords={*,...}, + numbers=left, + numbersep=10pt, + numberstyle=\tiny\color{black}, + rulecolor=\color{black}, + showspaces=false, + showstringspaces=false, + showtabs=false, + stepnumber=1, + stringstyle=\color{gray}, + tabsize=4, + title=\lstname, +} + +\pagestyle{empty} +\geometry{left=10mm,right=10mm, top=7mm, bottom=7mm} + +\author{} +\title{} +\date{} + +\begin{document} + +\begin{minipage}{0.4\textwidth} + \lstinputlisting[language=Python]{tri_bulles.py} +\end{minipage} +\hfill +\begin{minipage}{0.55\textwidth} + \includegraphics[height=250pt, width=430pt, keepaspectratio]{./fig/2nd6_bulles} +\end{minipage} + +\begin{minipage}{0.4\textwidth} + \lstinputlisting[language=Python]{tri_min.py} +\end{minipage} +\hfill +\begin{minipage}{0.55\textwidth} + \includegraphics[height=280pt, width=430pt, keepaspectratio]{./fig/2nd6_min} +\end{minipage} + +\end{document} diff --git a/PreStSauveur/2nd/Algo/Tri/bilan.pdf b/PreStSauveur/2nd/Algo/Tri/bilan.pdf new file mode 100644 index 0000000..f1d3f9c Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/bilan.pdf differ diff --git a/PreStSauveur/2nd/Algo/Tri/bilan.tex b/PreStSauveur/2nd/Algo/Tri/bilan.tex new file mode 100755 index 0000000..8abd7c9 --- /dev/null +++ b/PreStSauveur/2nd/Algo/Tri/bilan.tex @@ -0,0 +1,95 @@ +\documentclass[a4paper,10pt, landscape]{classCours} +\usepackage{listings} + +\definecolor{darkWhite}{rgb}{0.94,0.94,0.94} + +\lstset{ + aboveskip=1mm, + belowskip=-1mm, + backgroundcolor=\color{darkWhite}, + basicstyle=\footnotesize, + breakatwhitespace=false, + breaklines=true, + captionpos=b, + commentstyle=\color{red}, + deletekeywords={...}, + escapeinside={\%*}{*)}, + extendedchars=true, + framexleftmargin=16pt, + framextopmargin=3pt, + framexbottommargin=3pt, + frame=tb, + keepspaces=true, + keywordstyle=\color{blue}, + language=Python, + literate= + {²}{{\textsuperscript{2}}}1 + {⁴}{{\textsuperscript{4}}}1 + {⁶}{{\textsuperscript{6}}}1 + {⁸}{{\textsuperscript{8}}}1 + {€}{{\euro{}}}1 + {é}{{\'e}}1 + {è}{{\`{e}}}1 + {ê}{{\^{e}}}1 + {ë}{{\¨{e}}}1 + {É}{{\'{E}}}1 + {Ê}{{\^{E}}}1 + {û}{{\^{u}}}1 + {ù}{{\`{u}}}1 + {â}{{\^{a}}}1 + {à}{{\`{a}}}1 + {á}{{\'{a}}}1 + {ã}{{\~{a}}}1 + {Á}{{\'{A}}}1 + {Â}{{\^{A}}}1 + {Ã}{{\~{A}}}1 + {ç}{{\c{c}}}1 + {Ç}{{\c{C}}}1 + {õ}{{\~{o}}}1 + {ó}{{\'{o}}}1 + {ô}{{\^{o}}}1 + {Õ}{{\~{O}}}1 + {Ó}{{\'{O}}}1 + {Ô}{{\^{O}}}1 + {î}{{\^{i}}}1 + {Î}{{\^{I}}}1 + {í}{{\'{i}}}1 + {Í}{{\~{Í}}}1, + morekeywords={*,...}, + numbers=left, + numbersep=10pt, + numberstyle=\tiny\color{black}, + rulecolor=\color{black}, + showspaces=false, + showstringspaces=false, + showtabs=false, + stepnumber=1, + stringstyle=\color{gray}, + tabsize=4, + title=\lstname, +} + +\pagestyle{empty} +\geometry{left=10mm,right=10mm, top=7mm, bottom=7mm} + +\author{} +\title{} +\date{} + +\begin{document} + +\begin{minipage}{0.5\textwidth} + \lstinputlisting[language=Python]{tri_bulles.py} +\end{minipage} +\begin{minipage}{0.5\textwidth} + \includegraphics[height=250pt]{./fig/2nd2_bulles} +\end{minipage} + +\begin{minipage}{0.5\textwidth} + \lstinputlisting[language=Python]{tri_min.py} +\end{minipage} +\begin{minipage}{0.5\textwidth} + \includegraphics[height=280pt]{./fig/2nd2_min} +\end{minipage} + +\end{document} diff --git a/PreStSauveur/2nd/Algo/Tri/fig/2nd2_bulles.png b/PreStSauveur/2nd/Algo/Tri/fig/2nd2_bulles.png new file mode 100644 index 0000000..bb703b6 Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/fig/2nd2_bulles.png differ diff --git a/PreStSauveur/2nd/Algo/Tri/fig/2nd2_min.png b/PreStSauveur/2nd/Algo/Tri/fig/2nd2_min.png new file mode 100644 index 0000000..2b96aa4 Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/fig/2nd2_min.png differ diff --git a/PreStSauveur/2nd/Algo/Tri/fig/2nd3_bulles.png b/PreStSauveur/2nd/Algo/Tri/fig/2nd3_bulles.png new file mode 100644 index 0000000..fc82595 Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/fig/2nd3_bulles.png differ diff --git a/PreStSauveur/2nd/Algo/Tri/fig/2nd3_min.png b/PreStSauveur/2nd/Algo/Tri/fig/2nd3_min.png new file mode 100644 index 0000000..079f567 Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/fig/2nd3_min.png differ diff --git a/PreStSauveur/2nd/Algo/Tri/fig/2nd4_bulles.png b/PreStSauveur/2nd/Algo/Tri/fig/2nd4_bulles.png new file mode 100644 index 0000000..b530792 Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/fig/2nd4_bulles.png differ diff --git a/PreStSauveur/2nd/Algo/Tri/fig/2nd4_min.png b/PreStSauveur/2nd/Algo/Tri/fig/2nd4_min.png new file mode 100644 index 0000000..d80554b Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/fig/2nd4_min.png differ diff --git a/PreStSauveur/2nd/Algo/Tri/fig/2nd6_bulles.png b/PreStSauveur/2nd/Algo/Tri/fig/2nd6_bulles.png new file mode 100644 index 0000000..8371c6f Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/fig/2nd6_bulles.png differ diff --git a/PreStSauveur/2nd/Algo/Tri/fig/2nd6_min.png b/PreStSauveur/2nd/Algo/Tri/fig/2nd6_min.png new file mode 100644 index 0000000..ff0714c Binary files /dev/null and b/PreStSauveur/2nd/Algo/Tri/fig/2nd6_min.png differ diff --git a/PreStSauveur/2nd/Algo/Tri/index.rst b/PreStSauveur/2nd/Algo/Tri/index.rst index 39d6e85..0a71c4a 100644 --- a/PreStSauveur/2nd/Algo/Tri/index.rst +++ b/PreStSauveur/2nd/Algo/Tri/index.rst @@ -111,9 +111,9 @@ Productions d'élèves +---------+---+---+---+---+---+ | Min/max | | 2 | 2 | 2 | 4 | +---------+---+---+---+---+---+ -| Bulles | | 0 | 0 | 0 | 0 | +| Bulles | | 1 | 2 | 2 | 1 | +---------+---+---+---+---+---+ -| Monté/descente -> plus bouger | | 1 | 2 | 2 | 1 | +| Bulles amélioré | | 0 | 0 | 0 | 0 | +---------+---+---+---+---+---+ | Insertion | | 0 | 1 | 0 | 0 | +---------+---+---+---+---+---+ diff --git a/PreStSauveur/2nd/Algo/Tri/tri_bulles.py b/PreStSauveur/2nd/Algo/Tri/tri_bulles.py new file mode 100644 index 0000000..bb3e672 --- /dev/null +++ b/PreStSauveur/2nd/Algo/Tri/tri_bulles.py @@ -0,0 +1,26 @@ +##### Initialisation +# la liste des cartes +cartes = [101011, 110111, 100111, 101010, 101100] + +##### Tri +echange = True +# tant qu'on a échangé des cartes on continue à les ranger +while echange: + # Au début on a rien échangé + echange = False + # On va comparer les cartes 2 à 2 + # i va décrire la position de la carte + # On va la comparer avec la suivante (i+1) + # i va aller de 1 au nombre de carte-1 + for i in range(0, len(cartes)-1): + if cartes[i] > cartes[i+1]: + # si la carte i est plus grande que la carte i+1 + # on les échanges + cartes[i], cartes[i+1] = cartes[i+1], cartes[i] + # On a fait un échange + echange = True + +###### Fin +# On affiche les cartes triées +print(cartes) + diff --git a/PreStSauveur/2nd/Algo/Tri/tri_min.py b/PreStSauveur/2nd/Algo/Tri/tri_min.py new file mode 100644 index 0000000..84c8bbb --- /dev/null +++ b/PreStSauveur/2nd/Algo/Tri/tri_min.py @@ -0,0 +1,28 @@ +##### Initialisation +# la liste des cartes +cartes = [101011, 110111, 100111, 101010, 101100] +# On rangera dant cartes_triees +cartes_triees = [] + +##### Tri +# tant qu'il reste des nombres dans cartes +# len compte les éléments d'une liste +while len(cartes) > 0: + # On prend la première carte grâce au [0] + candidat_min = cartes[0] + # On va la comparer avec toutes les autres + # i est la position de la carte à comparer il ira de 1 à len(carte) + for i in range(1, len(cartes)) : + # on compare la carte minimum à une carte + if candidat_min > cartes[i]: + # quand la carte est plus petite c'est celle là que l'on veut garder + candidat_min = cartes[i] + # On ajoute la plus petite dans la liste des cartes triées + cartes_triees.append(candidat_min) + # On la supprime des cartes à trier + cartes.remove(candidat_min) + +##### Fin +# On affiche les cartes triées +print(cartes_triees) +