




def 							_A       (						lowerCAmelCase_					: int      ):
     """simple docstring"""

     lowerCAmelCase__          =			generate_pascal_triangle(lowerCAmelCase_      )
     for row_idx in range(lowerCAmelCase_      ):
          # Print left spaces
          for _ in range(num_rows - row_idx - 1      ):
               print(end=" "      )
          # Print row values
          for col_idx in range(row_idx + 1      ):
               if col_idx != row_idx:
                    print(triangle[row_idx][col_idx]       ,    end=" "      )
               else:
                    print(triangle[row_idx][col_idx]       ,    end=""      )
          print()



def 							_A       (						lowerCAmelCase_					: Union[str, Any]      ):
     """simple docstring"""

     if not isinstance(lowerCAmelCase_       ,    lowerCAmelCase_      ):
          raise TypeError("The input value of \'num_rows\' should be \'int\'"      )

     if num_rows == 0:
          return []
     elif num_rows < 0:
          raise ValueError(
              "The input value of \'num_rows\' should be greater than or equal to 0"      )

     lowerCAmelCase__          =			[]
     for current_row_idx in range(lowerCAmelCase_      ):
          lowerCAmelCase__          =			populate_current_row(lowerCAmelCase_       ,    lowerCAmelCase_      )
          triangle.append(lowerCAmelCase_      )
     return triangle



def 							_A       (						lowerCAmelCase_					: Union[str, Any]       ,    lowerCAmelCase_					: Dict      ):
     """simple docstring"""

     lowerCAmelCase__          =			[-1] * (current_row_idx + 1)
     # first and last elements of current row are equal to 1
     lowerCAmelCase__     ,		lowerCAmelCase__          =			1, 1
     for current_col_idx in range(1       ,    lowerCAmelCase_      ):
          calculate_current_element(
              lowerCAmelCase_       ,    lowerCAmelCase_       ,    lowerCAmelCase_       ,    lowerCAmelCase_      )
     return current_row



def 							_A       (						lowerCAmelCase_					: List[Any]       ,    lowerCAmelCase_					: Dict       ,    lowerCAmelCase_					: Optional[int]       ,    lowerCAmelCase_					: Dict       ,    ):
     """simple docstring"""

     lowerCAmelCase__          =			triangle[current_row_idx - 1][current_col_idx - 1]
     lowerCAmelCase__          =			triangle[current_row_idx - 1][current_col_idx]
     lowerCAmelCase__          =			above_to_left_elt + above_to_right_elt



def 							_A       (						lowerCAmelCase_					: Union[str, Any]      ):
     """simple docstring"""

     if not isinstance(lowerCAmelCase_       ,    lowerCAmelCase_      ):
          raise TypeError("The input value of \'num_rows\' should be \'int\'"      )

     if num_rows == 0:
          return []
     elif num_rows < 0:
          raise ValueError(
              "The input value of \'num_rows\' should be greater than or equal to 0"      )

     lowerCAmelCase__          =			[[1]]

     for row_index in range(1       ,    lowerCAmelCase_      ):
          lowerCAmelCase__          =			[0] + result[-1] + [0]
          lowerCAmelCase__          =			row_index + 1
          # Calculate the number of distinct elements in a row
          lowerCAmelCase__          =			sum(divmod(lowerCAmelCase_       ,    2      )      )
          lowerCAmelCase__          =			[
              temp_row[i - 1] + temp_row[i] for i in range(1       ,    distinct_elements + 1      )
          ]
          lowerCAmelCase__          =			row_first_half[: (row_index + 1) // 2]
          row_second_half.reverse()
          lowerCAmelCase__          =			row_first_half + row_second_half
          result.append(lowerCAmelCase_      )

     return result



def 							_A       (						):
     """simple docstring"""

     from collections.abc import Callable
     from timeit import timeit

     def benchmark_a_function(lowerCAmelCase_					: Optional[int]       ,    lowerCAmelCase_					: List[Any]      ) -> None:
          lowerCAmelCase__          =			F'{func.__name__}({value})'
          lowerCAmelCase__          =			timeit(F'__main__.{call}'       ,    setup="import __main__"      )
          # print(f"{call:38} = {func(value)} -- {timing:.4f} seconds")
          print(F'{call:38} -- {timing:.4f} seconds'      )

     for value in range(15      ):  # (1, 7, 14):
          for func in (generate_pascal_triangle, generate_pascal_triangle_optimized):
               benchmark_a_function(lowerCAmelCase_       ,    lowerCAmelCase_      )
          print()


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     benchmark()






from maths.prime_factors import prime_factors



def 							_A       (						lowerCAmelCase_					: int      ):
     """simple docstring"""

     if not isinstance(lowerCAmelCase_       ,    lowerCAmelCase_      ):
          lowerCAmelCase__          =			F'Input value of [number={number}] must be an integer'
          raise TypeError(lowerCAmelCase_      )
     if number < 1:
          raise ValueError("Input must be a positive integer"      )
     return -1 if len(prime_factors(lowerCAmelCase_      )      ) % 2 else 1


if __name__ == "__main__":
     import doctest

     doctest.testmod()
