mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-06-18 20:09:43 -04:00
simple examples, glassdoor
This commit is contained in:
parent
87a257c09c
commit
ee01cd9446
25 changed files with 484 additions and 6 deletions
src/extra_interview_problems/advanced
15
src/extra_interview_problems/advanced/lru_cache.py
Normal file
15
src/extra_interview_problems/advanced/lru_cache.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/python3
|
||||
|
||||
from functools import lru_cache
|
||||
|
||||
|
||||
@lru_cache(maxsize=20)
|
||||
def fib(n):
|
||||
if n < 2:
|
||||
return n
|
||||
return fib(n-1) + fib(n-2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print([fib(n) for n in range(10)])
|
||||
print(fib.cache_info())
|
Loading…
Add table
Add a link
Reference in a new issue