interview problems: trees

This commit is contained in:
Mari Wahl 2015-01-06 18:05:11 -05:00
parent e31b9e4d5f
commit a4637a3411
66 changed files with 406 additions and 533 deletions

View file

@ -0,0 +1,18 @@
#!/usr/bin/env python3
__author__ = "bt3"
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())