This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fast_doubling_fibonacci_iterative(n): | |
| """ | |
| Args: | |
| n (): | |
| Returns: | |
| >>> fast_doubling_fibonacci_iterative(80) | |
| 23416728348467685 | |
| >>> fast_doubling_fibonacci_iterative(800) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fast_doubling_fibonacci_iterative(n): | |
| """ | |
| Args: | |
| n (): | |
| Returns: | |
| >>> fast_doubling_fibonacci_iterative(80) | |
| 23416728348467685 | |
| >>> fast_doubling_fibonacci_iterative(800) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from timeit import * | |
| def collect_results(): | |
| results = [] | |
| for i in range(1000, 2000001, 100000): | |
| f = "fast_doubling_fibonacci_recursive" | |
| t1 = Timer(f"{f}({i})", | |
| f"from __main__ import {f}") | |
| st1 = t1.timeit(number=10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def collect_results(): | |
| results = [] | |
| for i in range(1000, 2000001, 100000): | |
| f = "fast_doubling_fibonacci_recursive" | |
| t1 = Timer(f"{f}({i})", | |
| f"from __main__ import {f}") | |
| st1 = t1.timeit(number=10) | |
| f = "matrix_fibonacci" | |
| t2 = Timer(f"{f}({i})", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from timeit import * | |
| def collect_results(): | |
| results = [] | |
| for i in range(1000, 2000001, 100000): | |
| f = "fast_doubling_fibonacci_recursive" | |
| t1 = Timer(f"{f}({i})", | |
| f"from __main__ import {f}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| class Square: | |
| length: int | |
| def __init__(self, length=0): | |
| self.length = length | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def area(any_object): | |
| if isinstance(any_object, Circle): | |
| return math.pi * (math.pow(any_object.radius, 2)) | |
| elif isinstance(any_object, Square): | |
| return (math.pow(any_object.length, 2)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| my_circle = Circle(6) | |
| my_square = Square(12) | |
| print(area(my_circle)) | |
| print(area(my_square)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| class Square: | |
| length: int | |
| def __init__(self, length=0): | |
| self.length = length | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from functools import singledispatch | |
| @singledispatch | |
| def area(any_object): | |
| raise NotImplementedError | |
| @area.register(Circle) | |
| def _(any_object): | |
| return math.pi * (math.pow(any_object.radius, 2)) |