File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ def generate_pascal_triangle(num_rows: int) -> list[list[int]]:
7474 triangle .append (current_row )
7575 return triangle
7676
77+
7778def populate_current_row (triangle : list [list [int ]], current_row_idx : int ) -> list [int ]:
7879 """
7980 >>> triangle = [[1]]
@@ -112,10 +113,10 @@ def generate_pascal_triangle_optimized(num_rows: int) -> list[list[int]]:
112113 """
113114 Returns a matrix representing Pascal's triangle.
114115 Reduces operations by half by eliminating redundant calculations.
115-
116+
116117 :param num_rows: Number of rows in the Pascal's triangle
117118 :return: 2D list representing the Pascal's triangle
118-
119+
119120 >>> generate_pascal_triangle_optimized(3)
120121 [[1], [1, 1], [1, 2, 1]]
121122 >>> generate_pascal_triangle_optimized(1)
@@ -158,11 +159,11 @@ def generate_pascal_triangle_optimized(num_rows: int) -> list[list[int]]:
158159 return result
159160
160161
161-
162162def benchmark () -> None :
163163 """
164164 Benchmark functions with different input sizes
165165 """
166+
166167 def benchmark_a_function (func : Callable , value : int ) -> None :
167168 call = f"{ func .__name__ } ({ value } )"
168169 timing = timeit (f"__main__.{ call } " , setup = "import __main__" )
You can’t perform that action at this time.
0 commit comments