init: initial commit

This commit is contained in:
mau
2026-06-12 20:35:24 +02:00
parent 6232adcca9
commit 3bda02f563
5 changed files with 61 additions and 3 deletions
+3 -3
View File
@@ -121,8 +121,8 @@ celerybeat.pid
*.sage.py *.sage.py
# Environments # Environments
.env .env/
.venv .venv/
env/ env/
venv/ venv/
ENV/ ENV/
@@ -158,5 +158,5 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear # and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ .idea/
+24
View File
@@ -0,0 +1,24 @@
class LRUCache:
def __init__(self, capacity: int):
self.capacity = capacity
self.slots = []
def get(self, key: int) -> int:
if key <= len(self.slots) -1:
return self.slots[key]
return -1
def put(self, key: int, value: int) -> None:
if self.capacity > len(self.slots):
self.slots.append(value)
else:
self.slots[len(self.slots) - 1] = value
def main():
cache = LRUCache(2)
print(cache.get(1))
print(cache.get(0))
if __name__ == "__main__":
main()
+5
View File
@@ -0,0 +1,5 @@
[project]
name = "training-cg"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = []
+21
View File
@@ -0,0 +1,21 @@
def filter_keywords(text: str, keywords: list[str]) -> list[str]:
"""
Prend un texte et une liste de motsclés (insensibles à la casse).
Retourne les mots du texte (sans ponctuation) qui contiennent au moins un motclé.
Si un mot du texte contient plusieurs motsclés, il nest listé quune fois.
"""
res = []
for word in keywords:
nb_occ = text.lower().count(word.lower())
res.extend([word] * nb_occ)
return res
def main():
text = "Python est génial ! J'adore Python, surtout les listes."
keywords = ["python", "liste"]
print(filter_keywords(text, keywords))
if __name__ == "__main__":
main()
Generated
+8
View File
@@ -0,0 +1,8 @@
version = 1
revision = 1
requires-python = ">=3.12"
[[package]]
name = "training-cg"
version = "0.1.0"
source = { virtual = "." }