mirror of
https://github.com/Fare-spec/cours.git
synced 2025-12-07 10:50:36 +00:00
my version
This commit is contained in:
170
README.html
Normal file
170
README.html
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="ISO-8859-1">
|
||||||
|
<title>Source file</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="highlight.css">
|
||||||
|
</head>
|
||||||
|
<body class="hl">
|
||||||
|
<pre class="hl">.
|
||||||
|
├── algo2.md
|
||||||
|
├── casse-brique
|
||||||
|
│ ├── main.py
|
||||||
|
│ └── pygame.py
|
||||||
|
├── cesar
|
||||||
|
│ ├── chiffrement.py
|
||||||
|
│ ├── message2.txt
|
||||||
|
│ └── message.txt
|
||||||
|
├── crypto
|
||||||
|
│ ├── algo.py
|
||||||
|
│ └── message
|
||||||
|
├── Dijkstra
|
||||||
|
│ ├── algo.py
|
||||||
|
│ └── fonctions.md
|
||||||
|
├── ensembles_dynamiques
|
||||||
|
│ └── TP
|
||||||
|
│ ├── _collection_list.py
|
||||||
|
│ ├── _collection.py
|
||||||
|
│ ├── data
|
||||||
|
│ │ └── Chartreuse.csv
|
||||||
|
│ ├── main.py
|
||||||
|
│ ├── _sommets_dict.py
|
||||||
|
│ └── _sommets.py
|
||||||
|
├── fibonacci
|
||||||
|
│ ├── code1.py
|
||||||
|
│ ├── complex.py
|
||||||
|
│ └── fibobo
|
||||||
|
│ ├── Cargo.lock
|
||||||
|
│ ├── Cargo.toml
|
||||||
|
│ └── src
|
||||||
|
│ └── main.rs
|
||||||
|
├── fichier.md
|
||||||
|
├── file
|
||||||
|
│ └── new
|
||||||
|
│ └── fifo.py
|
||||||
|
├── fonctions_tri
|
||||||
|
│ └── partitionement.py
|
||||||
|
├── get_bac_subject
|
||||||
|
│ └── get_bac_subject
|
||||||
|
│ ├── Cargo.lock
|
||||||
|
│ ├── Cargo.toml
|
||||||
|
│ ├── src
|
||||||
|
│ │ └── main.rs
|
||||||
|
│ └── url.txt
|
||||||
|
├── graphes
|
||||||
|
│ ├── DS_possible
|
||||||
|
│ │ ├── main.py
|
||||||
|
│ │ └── v
|
||||||
|
│ ├── homework_wednesday.py
|
||||||
|
│ ├── ht
|
||||||
|
│ ├── leaudibidon
|
||||||
|
│ │ ├── correction.py
|
||||||
|
│ │ ├── main.py
|
||||||
|
│ │ └── Water_jug.py
|
||||||
|
│ ├── maze
|
||||||
|
│ │ ├── fifo.py
|
||||||
|
│ │ ├── lifo.py
|
||||||
|
│ │ ├── main.py
|
||||||
|
│ │ ├── maze_creator.py
|
||||||
|
│ │ └── test.py
|
||||||
|
│ ├── monday_homework.py
|
||||||
|
│ └── why
|
||||||
|
├── highlight.css
|
||||||
|
├── LICENSE
|
||||||
|
├── magic_square
|
||||||
|
│ ├── magic_square.py
|
||||||
|
│ ├── td_carre_magique.py
|
||||||
|
│ └── TDliste2liste
|
||||||
|
│ ├── exercice1.py
|
||||||
|
│ ├── exercice2.py
|
||||||
|
│ ├── exercice3.py
|
||||||
|
│ ├── exercice4.py
|
||||||
|
│ ├── exercice5.py
|
||||||
|
│ └── exercice6.py
|
||||||
|
├── Partie2
|
||||||
|
│ └── Eleve
|
||||||
|
│ ├── livres.db
|
||||||
|
│ ├── livres.db-journal
|
||||||
|
│ ├── livres.sql
|
||||||
|
│ ├── p_app_web_python_sqlite.pdf
|
||||||
|
│ ├── Projet
|
||||||
|
│ │ ├── control.py
|
||||||
|
│ │ ├── index.html
|
||||||
|
│ │ ├── __init__.py
|
||||||
|
│ │ └── templates
|
||||||
|
│ │ └── index.html
|
||||||
|
│ └── run.py
|
||||||
|
├── partition_fusion
|
||||||
|
│ ├── code2.py
|
||||||
|
│ ├── code.py
|
||||||
|
│ ├── liste.py
|
||||||
|
│ └── partition_fusion.py
|
||||||
|
├── perfect_number
|
||||||
|
│ └── main.py
|
||||||
|
├── prblm.txt
|
||||||
|
├── prep
|
||||||
|
├── preuve.md
|
||||||
|
├── programmation_dynamique
|
||||||
|
│ ├── bag
|
||||||
|
│ │ └── main.py
|
||||||
|
│ └── monnaie
|
||||||
|
│ ├── piece1.py
|
||||||
|
│ └── piece.py
|
||||||
|
├── question_du_jour
|
||||||
|
│ ├── 05-05-2025
|
||||||
|
│ │ └── pro_dynamique.py
|
||||||
|
│ └── 12-05-2025
|
||||||
|
│ └── main.py
|
||||||
|
├── readme_creator.txt
|
||||||
|
├── README.html
|
||||||
|
├── README.md
|
||||||
|
├── recursivite
|
||||||
|
│ ├── exercice_MJoannic
|
||||||
|
│ │ ├── dichotomie
|
||||||
|
│ │ │ ├── iteratif
|
||||||
|
│ │ │ │ ├── main.py
|
||||||
|
│ │ │ │ ├── sort_list.py
|
||||||
|
│ │ │ │ └── tester.py
|
||||||
|
│ │ │ └── recursif
|
||||||
|
│ │ │ ├── correction
|
||||||
|
│ │ │ │ └── V1.py
|
||||||
|
│ │ │ └── myself
|
||||||
|
│ │ │ ├── idx
|
||||||
|
│ │ │ │ ├── main.py
|
||||||
|
│ │ │ │ ├── sort_list.py
|
||||||
|
│ │ │ │ └── tester.py
|
||||||
|
│ │ │ ├── main.py
|
||||||
|
│ │ │ ├── sort_list.py
|
||||||
|
│ │ │ └── tester.py
|
||||||
|
│ │ ├── palindrom.py
|
||||||
|
│ │ └── sqrt
|
||||||
|
│ │ ├── correction
|
||||||
|
│ │ │ └── main.py
|
||||||
|
│ │ └── main.py
|
||||||
|
│ └── TD1.py
|
||||||
|
├── sqlite
|
||||||
|
│ ├── test
|
||||||
|
│ └── test-journal
|
||||||
|
├── TDliste2liste
|
||||||
|
│ ├── exercice1.py
|
||||||
|
│ ├── exercice2.py
|
||||||
|
│ ├── exercice3.py
|
||||||
|
│ ├── exercice4.py
|
||||||
|
│ ├── exercice5.py
|
||||||
|
│ └── exercice6.py
|
||||||
|
└── trees
|
||||||
|
├── AB
|
||||||
|
│ └── arbre.py
|
||||||
|
├── ABR
|
||||||
|
│ └── main.py
|
||||||
|
├── genealogie
|
||||||
|
│ ├── genealogie.csv
|
||||||
|
│ ├── genealogie.py
|
||||||
|
│ └── TP_Arbres_Generalites.pdf?forcedownload=1
|
||||||
|
└── qdj.py
|
||||||
|
|
||||||
|
52 directories, 104 files
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
<!--HTML generated by highlight 4.13, http://andre-simon.de/-->
|
||||||
127
README.md
127
README.md
@@ -9,9 +9,18 @@
|
|||||||
<pre class="hl">.
|
<pre class="hl">.
|
||||||
├── algo2.md
|
├── algo2.md
|
||||||
├── casse-brique
|
├── casse-brique
|
||||||
│ └── main.py
|
│ ├── main.py
|
||||||
|
│ └── pygame.py
|
||||||
|
├── cesar
|
||||||
|
│ ├── chiffrement.py
|
||||||
|
│ ├── message2.txt
|
||||||
|
│ └── message.txt
|
||||||
|
├── crypto
|
||||||
|
│ ├── algo.py
|
||||||
|
│ └── message
|
||||||
├── Dijkstra
|
├── Dijkstra
|
||||||
│ └── algo.py
|
│ ├── algo.py
|
||||||
|
│ └── fonctions.md
|
||||||
├── ensembles_dynamiques
|
├── ensembles_dynamiques
|
||||||
│ └── TP
|
│ └── TP
|
||||||
│ ├── _collection_list.py
|
│ ├── _collection_list.py
|
||||||
@@ -31,18 +40,19 @@
|
|||||||
│ └── main.rs
|
│ └── main.rs
|
||||||
├── fichier.md
|
├── fichier.md
|
||||||
├── file
|
├── file
|
||||||
│ ├── new
|
│ └── new
|
||||||
│ │ └── fifo.py
|
│ └── fifo.py
|
||||||
│ └── old
|
|
||||||
│ ├── file_LSC.py
|
|
||||||
│ ├── file.py
|
|
||||||
│ ├── file_tuple.py
|
|
||||||
│ └── LSC.py
|
|
||||||
├── fonctions_tri
|
├── fonctions_tri
|
||||||
│ └── partitionement.py
|
│ └── partitionement.py
|
||||||
|
├── get_bac_subject
|
||||||
|
│ └── get_bac_subject
|
||||||
|
│ ├── Cargo.lock
|
||||||
|
│ ├── Cargo.toml
|
||||||
|
│ ├── src
|
||||||
|
│ │ └── main.rs
|
||||||
|
│ └── url.txt
|
||||||
├── graphes
|
├── graphes
|
||||||
│ ├── DS_possible
|
│ ├── DS_possible
|
||||||
│ │ ├── elouan_fare.tar
|
|
||||||
│ │ ├── main.py
|
│ │ ├── main.py
|
||||||
│ │ └── v
|
│ │ └── v
|
||||||
│ ├── homework_wednesday.py
|
│ ├── homework_wednesday.py
|
||||||
@@ -50,7 +60,6 @@
|
|||||||
│ ├── leaudibidon
|
│ ├── leaudibidon
|
||||||
│ │ ├── correction.py
|
│ │ ├── correction.py
|
||||||
│ │ ├── main.py
|
│ │ ├── main.py
|
||||||
│ │ ├── Water_jug(en_xz).tar
|
|
||||||
│ │ └── Water_jug.py
|
│ │ └── Water_jug.py
|
||||||
│ ├── maze
|
│ ├── maze
|
||||||
│ │ ├── fifo.py
|
│ │ ├── fifo.py
|
||||||
@@ -87,33 +96,27 @@
|
|||||||
│ └── run.py
|
│ └── run.py
|
||||||
├── partition_fusion
|
├── partition_fusion
|
||||||
│ ├── code2.py
|
│ ├── code2.py
|
||||||
│ └── code.py
|
│ ├── code.py
|
||||||
|
│ ├── liste.py
|
||||||
|
│ └── partition_fusion.py
|
||||||
|
├── perfect_number
|
||||||
|
│ └── main.py
|
||||||
├── prblm.txt
|
├── prblm.txt
|
||||||
|
├── prep
|
||||||
├── preuve.md
|
├── preuve.md
|
||||||
├── pygame
|
├── programmation_dynamique
|
||||||
│ ├── bouncing_ball
|
│ ├── bag
|
||||||
│ │ ├── balle.py
|
|
||||||
│ │ ├── ball.py
|
|
||||||
│ │ ├── constantes.py
|
|
||||||
│ │ ├── f
|
|
||||||
│ │ └── raquette.py
|
|
||||||
│ ├── bouncing_ball_project
|
|
||||||
│ │ ├── balle.py
|
|
||||||
│ │ ├── ball.py
|
|
||||||
│ │ ├── bouncing_ball_game.py
|
|
||||||
│ │ ├── constantes.py
|
|
||||||
│ │ └── raquette.py
|
|
||||||
│ ├── bouncing_ball_project.zip
|
|
||||||
│ ├── lab_py
|
|
||||||
│ │ └── main.py
|
│ │ └── main.py
|
||||||
│ └── V2
|
│ └── monnaie
|
||||||
│ └── balle
|
│ ├── piece1.py
|
||||||
│ ├── balle.py
|
│ └── piece.py
|
||||||
│ ├── balle_rebondissante.py
|
├── question_du_jour
|
||||||
│ ├── casse_brique.py
|
│ ├── 05-05-2025
|
||||||
│ ├── constantes.py
|
│ │ └── pro_dynamique.py
|
||||||
│ └── raquette.py
|
│ └── 12-05-2025
|
||||||
|
│ └── main.py
|
||||||
├── readme_creator.txt
|
├── readme_creator.txt
|
||||||
|
├── README.html
|
||||||
├── README.md
|
├── README.md
|
||||||
├── recursivite
|
├── recursivite
|
||||||
│ ├── exercice_MJoannic
|
│ ├── exercice_MJoannic
|
||||||
@@ -149,52 +152,20 @@
|
|||||||
│ ├── exercice4.py
|
│ ├── exercice4.py
|
||||||
│ ├── exercice5.py
|
│ ├── exercice5.py
|
||||||
│ └── exercice6.py
|
│ └── exercice6.py
|
||||||
└── tp6_enirely
|
└── trees
|
||||||
├── tp6
|
├── AB
|
||||||
│ ├── LSC.py
|
│ └── arbre.py
|
||||||
│ ├── npi.py
|
├── ABR
|
||||||
│ ├── Pile_List.py
|
│ └── main.py
|
||||||
│ ├── Pile_LSC.py
|
├── genealogie
|
||||||
│ ├── Pile_Tuple.py
|
│ ├── genealogie.csv
|
||||||
│ ├── README.md
|
│ ├── genealogie.py
|
||||||
│ ├── test.py
|
│ └── TP_Arbres_Generalites.pdf?forcedownload=1
|
||||||
│ └── TP_Piles.pdf
|
└── qdj.py
|
||||||
├── TP6
|
|
||||||
│ ├── LSC.py
|
|
||||||
│ ├── Pile_List.py
|
|
||||||
│ ├── Pile_LSC.py
|
|
||||||
│ ├── Pile_Tuple.py
|
|
||||||
│ ├── test_2.py
|
|
||||||
│ │ ├── modules.rst
|
|
||||||
│ │ ├── Pile_List.rst
|
|
||||||
│ │ ├── Pile_Tuple.rst
|
|
||||||
│ │ └── test.rst
|
|
||||||
│ ├── test.py
|
|
||||||
│ ├── test.py.patch
|
|
||||||
│ └── TP_Piles.pdf
|
|
||||||
├── tp6_self
|
|
||||||
│ ├── LSC.py
|
|
||||||
│ ├── npi.py
|
|
||||||
│ ├── Pile_List.py
|
|
||||||
│ ├── Pile_LSC.py
|
|
||||||
│ ├── Pile_Tuple.py
|
|
||||||
│ ├── README.md
|
|
||||||
│ └── test.py
|
|
||||||
└── tp_listes_chaines
|
|
||||||
├── execute.py
|
|
||||||
├── fichiers
|
|
||||||
│ ├── Chartreuse.csv
|
|
||||||
│ ├── factorial.py
|
|
||||||
│ ├── LSC.py
|
|
||||||
│ ├── Sommets.py
|
|
||||||
│ ├── test.py
|
|
||||||
│ ├── TP5_1.py
|
|
||||||
│ └── TP5.py
|
|
||||||
├── TP 5 Listes Chaînées-20240925.zip
|
|
||||||
└── TP5_Listes_Chainees.pdf
|
|
||||||
|
|
||||||
49 directories, 137 files
|
52 directories, 104 files
|
||||||
</pre>
|
</pre>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
<!--HTML generated by highlight 4.13, http://andre-simon.de/-->
|
<!--HTML generated by highlight 4.13, http://andre-simon.de/-->
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ def sac_a_dos_glouton(videos, capacite, cle):
|
|||||||
return sélection, totale_duree, totale_taille
|
return sélection, totale_duree, totale_taille
|
||||||
|
|
||||||
|
|
||||||
'''def sac_a_dos_dynamique(videos, capacite):
|
"""def sac_a_dos_dynamique(videos, capacite):
|
||||||
precision = 100
|
precision = 100
|
||||||
capacite = int(capacite * precision)
|
capacite = int(capacite * precision)
|
||||||
liste = list(videos.items())
|
liste = list(videos.items())
|
||||||
@@ -122,22 +122,30 @@ def sac_a_dos_glouton(videos, capacite, cle):
|
|||||||
nom, info = liste[i - 1]
|
nom, info = liste[i - 1]
|
||||||
selection.append(nom)
|
selection.append(nom)
|
||||||
cap -= int(info["taille"] * precision)
|
cap -= int(info["taille"] * precision)
|
||||||
return selection[::-1]'''
|
return selection[::-1]"""
|
||||||
|
|
||||||
|
|
||||||
def sac_a_dos_dynamique(videos, capacite):
|
def sac_a_dos_dyn(videos, cap):
|
||||||
dp = [(0, []) for _ in range(capacite + 1)]
|
videos = [(d, int(t * 100)) for (d, t) in videos]
|
||||||
for nom, info in videos.items():
|
capacite = int(cap * 100)
|
||||||
duree = info['Durée']
|
n = len(videos)
|
||||||
taille = info['taille']
|
dp = [[0 for _ in range(capacite + 1)] for _ in range(n + 1)]
|
||||||
for c in range(capacite, taille - 1, -1):
|
for k in range(1, n + 1):
|
||||||
prev_duree, prev_sel = dp[c - taille]
|
duree_k, taille_k = videos[k - 1]
|
||||||
if prev_duree + duree > dp[c][0]:
|
for w in range(capacite + 1):
|
||||||
dp[c] = (prev_duree + duree, prev_sel + [nom])
|
if taille_k > w:
|
||||||
return dp[capacite][1]
|
dp[k][w] = dp[k - 1][w]
|
||||||
|
else:
|
||||||
|
dp[k][w] = max(dp[k - 1][w], duree_k + dp[k - 1][w - taille_k])
|
||||||
|
|
||||||
|
w = capacite
|
||||||
|
choix = []
|
||||||
|
for k in range(n, 0, -1):
|
||||||
|
if dp[k][w] != dp[k - 1][w]:
|
||||||
|
choix.append(k - 1)
|
||||||
|
w -= videos[k - 1][1]
|
||||||
|
|
||||||
|
return dp[n][capacite], list(reversed(choix))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ def force_brute(liste, i, j):
|
|||||||
|
|
||||||
|
|
||||||
def somme_max(liste):
|
def somme_max(liste):
|
||||||
max_actuel = max_total = liste[0]
|
max_actuel = max_total = liste[0]
|
||||||
for x in liste[1:]:
|
for x in liste[1:]:
|
||||||
max_actuel = max(x, max_actuel + x)
|
max_actuel = max(x, max_actuel + x)
|
||||||
max_total = max(max_total, max_actuel)
|
max_total = max(max_total, max_actuel)
|
||||||
|
|||||||
Reference in New Issue
Block a user