Challenge: Memoization Decorator
Tâche
Swipe to start coding
Write a decorator that caches the results of a function based on its arguments to avoid redundant calculations.
- The decorator must store the result of a function call using its positional and keyword arguments as the cache key.
- When the function is called again with the same arguments, the cached result must be returned instead of recomputing it.
- The decorator must work for functions with any number of positional and keyword arguments.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 4. Chapitre 2
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Awesome!
Completion rate improved to 5.88
Challenge: Memoization Decorator
Glissez pour afficher le menu
Tâche
Swipe to start coding
Write a decorator that caches the results of a function based on its arguments to avoid redundant calculations.
- The decorator must store the result of a function call using its positional and keyword arguments as the cache key.
- When the function is called again with the same arguments, the cached result must be returned instead of recomputing it.
- The decorator must work for functions with any number of positional and keyword arguments.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 4. Chapitre 2
single