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">.
|
||||
├── 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
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
<!--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
|
||||
|
||||
|
||||
'''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__":
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user