diff --git a/README.html b/README.html new file mode 100644 index 0000000..27bc6d3 --- /dev/null +++ b/README.html @@ -0,0 +1,170 @@ + + + + +Source file + + + +
.
+├── 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
+
+ + + diff --git a/README.md b/README.md index 64e7449..f70406e 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,18 @@
.
 ├── algo2.md
 ├── casse-brique
-│   └── main.py
+│   ├── main.py
+│   └── pygame.py
+├── cesar
+│   ├── chiffrement.py
+│   ├── message2.txt
+│   └── message.txt
+├── crypto
+│   ├── algo.py
+│   └── message
 ├── Dijkstra
-│   └── algo.py
+│   ├── algo.py
+│   └── fonctions.md
 ├── ensembles_dynamiques
 │   └── TP
 │       ├── _collection_list.py
@@ -31,18 +40,19 @@
 │           └── main.rs
 ├── fichier.md
 ├── file
-│   ├── new
-│   │   └── fifo.py
-│   └── old
-│       ├── file_LSC.py
-│       ├── file.py
-│       ├── file_tuple.py
-│       └── LSC.py
+│   └── 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
-│   │   ├── elouan_fare.tar
 │   │   ├── main.py
 │   │   └── v
 │   ├── homework_wednesday.py
@@ -50,7 +60,6 @@
 │   ├── leaudibidon
 │   │   ├── correction.py
 │   │   ├── main.py
-│   │   ├── Water_jug(en_xz).tar
 │   │   └── Water_jug.py
 │   ├── maze
 │   │   ├── fifo.py
@@ -87,33 +96,27 @@
 │       └── run.py
 ├── partition_fusion
 │   ├── code2.py
-│   └── code.py
+│   ├── code.py
+│   ├── liste.py
+│   └── partition_fusion.py
+├── perfect_number
+│   └── main.py
 ├── prblm.txt
+├── prep
 ├── preuve.md
-├── pygame
-│   ├── bouncing_ball
-│   │   ├── 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
+├── programmation_dynamique
+│   ├── bag
 │   │   └── main.py
-│   └── V2
-│       └── balle
-│           ├── balle.py
-│           ├── balle_rebondissante.py
-│           ├── casse_brique.py
-│           ├── constantes.py
-│           └── raquette.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
@@ -149,52 +152,20 @@
 │   ├── exercice4.py
 │   ├── exercice5.py
 │   └── exercice6.py
-└── tp6_enirely
-    ├── tp6
-    │   ├── LSC.py
-    │   ├── npi.py
-    │   ├── Pile_List.py
-    │   ├── Pile_LSC.py
-    │   ├── Pile_Tuple.py
-    │   ├── README.md
-    │   ├── test.py
-    │   └── TP_Piles.pdf
-    ├── 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
+└── trees
+    ├── AB
+    │   └── arbre.py
+    ├── ABR
+    │   └── main.py
+    ├── genealogie
+    │   ├── genealogie.csv
+    │   ├── genealogie.py
+    │   └── TP_Arbres_Generalites.pdf?forcedownload=1
+    └── qdj.py
 
-49 directories, 137 files
+52 directories, 104 files
 
+ \ No newline at end of file diff --git a/programmation_dynamique/bag/main.py b/programmation_dynamique/bag/main.py index 404aeff..160f62a 100644 --- a/programmation_dynamique/bag/main.py +++ b/programmation_dynamique/bag/main.py @@ -100,7 +100,7 @@ def sac_a_dos_glouton(videos, capacite, cle): return sélection, totale_duree, totale_taille -'''def sac_a_dos_dynamique(videos, capacite): +"""def sac_a_dos_dynamique(videos, capacite): precision = 100 capacite = int(capacite * precision) liste = list(videos.items()) @@ -122,22 +122,30 @@ def sac_a_dos_glouton(videos, capacite, cle): nom, info = liste[i - 1] selection.append(nom) cap -= int(info["taille"] * precision) - return selection[::-1]''' + return selection[::-1]""" -def sac_a_dos_dynamique(videos, capacite): - dp = [(0, []) for _ in range(capacite + 1)] - for nom, info in videos.items(): - duree = info['Durée'] - taille = info['taille'] - for c in range(capacite, taille - 1, -1): - prev_duree, prev_sel = dp[c - taille] - if prev_duree + duree > dp[c][0]: - dp[c] = (prev_duree + duree, prev_sel + [nom]) - return dp[capacite][1] - +def sac_a_dos_dyn(videos, cap): + videos = [(d, int(t * 100)) for (d, t) in videos] + capacite = int(cap * 100) + n = len(videos) + dp = [[0 for _ in range(capacite + 1)] for _ in range(n + 1)] + for k in range(1, n + 1): + duree_k, taille_k = videos[k - 1] + for w in range(capacite + 1): + if taille_k > w: + 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__": diff --git a/question_du_jour/12-05-2025/main.py b/question_du_jour/12-05-2025/main.py index 726479f..41f7ff2 100644 --- a/question_du_jour/12-05-2025/main.py +++ b/question_du_jour/12-05-2025/main.py @@ -7,7 +7,7 @@ def force_brute(liste, i, j): def somme_max(liste): - max_actuel = max_total = liste[0] + max_actuel = max_total = liste[0] for x in liste[1:]: max_actuel = max(x, max_actuel + x) max_total = max(max_total, max_actuel)