|
|
@ -1,95 +1,197 @@
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta charset="UTF-8" />
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Hanoi</title>
|
|
|
|
<title>Palindrome</title>
|
|
|
|
<link
|
|
|
|
<link rel="stylesheet" href="../../CSS/Enigme.css"/>
|
|
|
|
rel="stylesheet"
|
|
|
|
<link rel="stylesheet" href="../../CSS/Home.css">
|
|
|
|
href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
|
|
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
|
|
|
integrity="sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I"
|
|
|
|
<style>
|
|
|
|
crossorigin="anonymous"
|
|
|
|
html{
|
|
|
|
/>
|
|
|
|
background-image: url(../../../assets/img/Background5.jpg);
|
|
|
|
<script
|
|
|
|
}
|
|
|
|
src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
|
|
|
|
</style>
|
|
|
|
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
|
|
|
|
</head>
|
|
|
|
crossorigin="anonymous"
|
|
|
|
<body>
|
|
|
|
></script>
|
|
|
|
<div class="enigme">
|
|
|
|
<script
|
|
|
|
<div class="titre_pre">
|
|
|
|
src="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
|
|
|
|
<div class="retour">
|
|
|
|
integrity="sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
|
|
|
|
<a class="material-icons" id="home" href="../Home.html" style="font-size:36px;color:white;">home</a>
|
|
|
|
crossorigin="anonymous"
|
|
|
|
|
|
|
|
></script>
|
|
|
|
|
|
|
|
<link
|
|
|
|
|
|
|
|
rel="stylesheet"
|
|
|
|
|
|
|
|
href="https://fonts.googleapis.com/icon?family=Material+Icons"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="View/src/CSS/Enigme.css" />
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div class="container-fluid px-5">
|
|
|
|
|
|
|
|
<!-- First Row -->
|
|
|
|
|
|
|
|
<div class="row py-4">
|
|
|
|
|
|
|
|
<div class="col-9 d-flex align-items-center px-0">
|
|
|
|
|
|
|
|
<a
|
|
|
|
|
|
|
|
class="material-icons pl-0"
|
|
|
|
|
|
|
|
id="home"
|
|
|
|
|
|
|
|
href="index.php?action=goToHome"
|
|
|
|
|
|
|
|
style="font-size: 40px; color: white"
|
|
|
|
|
|
|
|
>home</a
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
style="background-color: transparent; border: none"
|
|
|
|
|
|
|
|
onclick="displayHelp()"
|
|
|
|
|
|
|
|
class="col-3 d-flex align-items-center"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<div class="col-10 text-right px-3">
|
|
|
|
|
|
|
|
<p style="font-size: 14px; color: white"><b>Besoin d'aide ?</b></p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-2 text-right">
|
|
|
|
|
|
|
|
<img
|
|
|
|
|
|
|
|
src="View/assets/img/Foxy.png"
|
|
|
|
|
|
|
|
alt="Logo"
|
|
|
|
|
|
|
|
class="rounded-circle moving-fox"
|
|
|
|
|
|
|
|
style="border: 1px solid #44fff6; width: 60px; height: 60px"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="sign">
|
|
|
|
<!-- End First Row -->
|
|
|
|
<h1>
|
|
|
|
|
|
|
|
<span class="fast-flicker">T</span>
|
|
|
|
<!-- Second Row -->
|
|
|
|
<span>our </span>
|
|
|
|
<div class="row">
|
|
|
|
<span class="flicker"> H</span>
|
|
|
|
<!-- First Column -->
|
|
|
|
<span>anoi</span>
|
|
|
|
<div
|
|
|
|
</h1>
|
|
|
|
class="col-3 rounded p-3"
|
|
|
|
</div><br>
|
|
|
|
style="background-color: #222831; min-height: 80vh; height: auto"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<h2 class="text-left py-3" style="color: #44fff6; font-weight: 500">
|
|
|
|
|
|
|
|
Les tours d'Hanoi
|
|
|
|
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
|
|
|
Écrire une fonction <b style="color: violet;">hanoi</b> permettant de résoudre le problème des <b>tours d’hanoi </b>
|
|
|
|
|
|
|
|
peu importe le nombre d'entrées dans la fonction. <br />
|
|
|
|
|
|
|
|
Cette fonction devra prend en paramètre le <b style="color: #44fff6;">nombre de disques</b>,
|
|
|
|
|
|
|
|
le <b style="color: #44fff6;">nom</b> de la tour de départ,
|
|
|
|
|
|
|
|
le <b style="color: #44fff6;">nom</b> la tour d'arrivée et
|
|
|
|
|
|
|
|
le <b style="color: #44fff6;">nom</b> la tour intermédiaire. <br />
|
|
|
|
|
|
|
|
Elle devra retoure une <b style="color: yellow;">liste</b> contenant les déplacements à effectuer (cf exemple ci-dessous).
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<h3 class="text-left pb-3 pt-5" style="color: #44fff6">Rappel</h3>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
|
|
|
Le problème des tours de <b>hanoi</b> est le suivant, on souhaite déplacer un certain nombre de disque de taille différente
|
|
|
|
|
|
|
|
et ils sont et doivent restés empilés de telle sorte
|
|
|
|
|
|
|
|
qu’aucun disque d’une certaine taille n soit placé en dessous d’un disque de taille plus grande
|
|
|
|
|
|
|
|
en sachant qu’il n’y a que 3 piles.
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<h3 class="text-left pb-3 pt-5" style="color: #44fff6">Exemple</h3>
|
|
|
|
|
|
|
|
<p><b>Entrée</b> :3,"A","B","C"</p>
|
|
|
|
|
|
|
|
<p><b>Sortie</b> : [['A','C'],['A','B'],['C','B'],['A','C'],['B','A'],['B','C'],['A','C']]</p>
|
|
|
|
|
|
|
|
<h3
|
|
|
|
|
|
|
|
class="text-left pb-3 pt-5 help"
|
|
|
|
|
|
|
|
style="color: #44fff6; display: none"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
Aide
|
|
|
|
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
<p style="display: none" class="help">
|
|
|
|
|
|
|
|
Pensse à utiliser une fonction récursive pour résoudre ce problème.
|
|
|
|
|
|
|
|
Pour rappel une fonction récursive est une fonction qui s'appelle elle même.
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- End First Column -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Second Column -->
|
|
|
|
|
|
|
|
<div class="col-5 pr-0">
|
|
|
|
|
|
|
|
<div class="ace rounded" id="editor">def hanoi(nb_disks,start, middle, end):
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<h2>Consigne</h2><br>
|
|
|
|
</div>
|
|
|
|
<p class="enonce">
|
|
|
|
<!-- End Second Column -->
|
|
|
|
Faire une fonction permettant de résoudre le problème des tours d’hanoi peu importe le nombre d'entrées dans la fonction.
|
|
|
|
|
|
|
|
</p><br>
|
|
|
|
|
|
|
|
<h2>Rappel</h2><br>
|
|
|
|
|
|
|
|
<p class="rappel">Le problème des tours de hanoi est le suivant, on souhaite déplacer un certain nombre de disque de taille différente et ils sont et doivent restés empilés de telle sorte qu’aucun disque d’une certaine taille n soit placé en dessous d’un disque de taille plus grande en sachant qu’il n’y a que 3 piles.
|
|
|
|
|
|
|
|
</p><br>
|
|
|
|
|
|
|
|
<h2>Exemple</h2><br>
|
|
|
|
|
|
|
|
<p>Entrée :3,"A","B","C"</p>
|
|
|
|
|
|
|
|
<p>Sortie : [['A','C'],['A','B'],['C','B'],['A','C'],['B','A'],['B','C'],['A','C']]</p>
|
|
|
|
|
|
|
|
<h2>Aide</h2><br>
|
|
|
|
|
|
|
|
<p>Une fonction récursive est une fonction qui fait appelle à elle même</p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='ace' id='editor'>def hanoi(nb_disks,start, middle, end):
|
|
|
|
|
|
|
|
l=[]
|
|
|
|
|
|
|
|
hanoi_rec(l,nb_disks,start, middle, end)
|
|
|
|
|
|
|
|
return l
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def hanoi_rec(l,nb_disks, start, middle, end):
|
|
|
|
<!-- Third Column -->
|
|
|
|
if nb_disks == 1:
|
|
|
|
<div class="col-4">
|
|
|
|
return l.append([start,end])
|
|
|
|
<textarea
|
|
|
|
else:
|
|
|
|
id="console"
|
|
|
|
hanoi_rec(l,nb_disks - 1, start, end, middle)
|
|
|
|
readonly
|
|
|
|
l.append([start,end])
|
|
|
|
style="width: 100%; min-height: 65vh; height: auto"
|
|
|
|
hanoi_rec(l,nb_disks - 1, middle, start, end)</div>
|
|
|
|
class="p-3 rounded"
|
|
|
|
<div class='compiler_class'>
|
|
|
|
></textarea>
|
|
|
|
<textarea id='console' readonly rows="30" cols="100"></textarea>
|
|
|
|
|
|
|
|
<div class="buttons">
|
|
|
|
<div class="row pt-5 text-center" style="cursor: pointer">
|
|
|
|
<div>
|
|
|
|
<div class="col-6">
|
|
|
|
<a onclick="run_init()" class="btn">
|
|
|
|
<a onclick="run_init()" class="btn">
|
|
|
|
<span class="noAnimation">Run</span>
|
|
|
|
<span>Run</span>
|
|
|
|
</a>
|
|
|
|
</a>
|
|
|
|
<a href="#m1-o" onclick="submit()" class="btn">
|
|
|
|
</div>
|
|
|
|
<span class="noAnimation">Submit</span>
|
|
|
|
<div class="col-6">
|
|
|
|
</a>
|
|
|
|
<button
|
|
|
|
|
|
|
|
onclick="submit()"
|
|
|
|
|
|
|
|
class="btn"
|
|
|
|
|
|
|
|
data-toggle="modal"
|
|
|
|
|
|
|
|
data-target="#modal"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<span>Submit</span>
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- End Third Column -->
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- End Second Row -->
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="modal-container" id="m1-o" style="--m-background: transparent;">
|
|
|
|
<!-- Modal -->
|
|
|
|
<div class="modal">
|
|
|
|
<div
|
|
|
|
<div id="containerResult">
|
|
|
|
class="modal fade"
|
|
|
|
<h1 id="result"></h1>
|
|
|
|
id="modal"
|
|
|
|
</div>
|
|
|
|
tabindex="-1"
|
|
|
|
<div class="buttons">
|
|
|
|
role="dialog"
|
|
|
|
<div id="top">
|
|
|
|
aria-labelledby="exampleModalCenterTitle"
|
|
|
|
<a href="#" class="btn">
|
|
|
|
aria-hidden="true"
|
|
|
|
<span class="noAnimation">x</span>
|
|
|
|
>
|
|
|
|
</a>
|
|
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
|
|
</div>
|
|
|
|
<div class="modal-content">
|
|
|
|
<div id="bottom">
|
|
|
|
<div class="modal-header">
|
|
|
|
<a href="../Home.html" class="btn" id="fleche">
|
|
|
|
<h2
|
|
|
|
<span class="noAnimation">Next</span>
|
|
|
|
class="modal-title"
|
|
|
|
</a>
|
|
|
|
id="exampleModalLongTitle"
|
|
|
|
|
|
|
|
style="color: black"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
Results
|
|
|
|
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
|
|
class="close"
|
|
|
|
|
|
|
|
data-dismiss="modal"
|
|
|
|
|
|
|
|
aria-label="Close"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="modal-body">
|
|
|
|
|
|
|
|
<h5 id="result" style="color: black"></h5>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="modal-footer">
|
|
|
|
|
|
|
|
<a href="index.php?action=goToTrianglePascal" class="btn" style="display: none" id="next">
|
|
|
|
|
|
|
|
<span>NEXT</span>
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- End Modal -->
|
|
|
|
<script src="https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
|
|
|
|
|
|
|
|
<script src="https://raw.githack.com/pythonpad/brython-runner/master/lib/brython-runner.bundle.js" type="text/javascript" charset="utf-8"></script>
|
|
|
|
<script
|
|
|
|
<script src="../../JS/base.js"></script>
|
|
|
|
src="https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js"
|
|
|
|
<script src="../../JS/Hanoi.js"></script>
|
|
|
|
type="text/javascript"
|
|
|
|
</body>
|
|
|
|
charset="utf-8"
|
|
|
|
|
|
|
|
></script>
|
|
|
|
|
|
|
|
<script
|
|
|
|
|
|
|
|
src="https://raw.githack.com/pythonpad/brython-runner/master/lib/brython-runner.bundle.js"
|
|
|
|
|
|
|
|
type="text/javascript"
|
|
|
|
|
|
|
|
charset="utf-8"
|
|
|
|
|
|
|
|
></script>
|
|
|
|
|
|
|
|
<script src="View/src/JS/base.js"></script>
|
|
|
|
|
|
|
|
<script src="View/src/JS/Hanoi.js"></script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
</html>
|
|
|
|