
"""simple docstring"""

def 		UpperCAmelCase (		a_      ):





		'''simple docstring'''


		lowerCamelCase					:      Optional[int]          =   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 		UpperCAmelCase (		a_      ):





		'''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					:      list[list[int]]          =   []
		for current_row_idx in range(_lowerCamelCase      ):
				lowerCamelCase					:      List[str]          =   populate_current_row(_lowerCamelCase,						_lowerCamelCase      )
				triangle.append(_lowerCamelCase      )
		return triangle
def 		UpperCAmelCase (		a_,						a_      ):





		'''simple docstring'''


		lowerCamelCase					:      Optional[Any]          =   [-1] * (current_row_idx + 1)
		# first and last elements of current row are equal to 1
		lowerCamelCase					:      List[str]          =   1, 1
		for current_col_idx in range(1,						_lowerCamelCase      ):
				calculate_current_element(
				    _lowerCamelCase,						_lowerCamelCase,						_lowerCamelCase,						_lowerCamelCase      )
		return current_row
def 		UpperCAmelCase (		a_,						a_,						a_,						a_,						):





		'''simple docstring'''


		lowerCamelCase					:      List[str]          =   triangle[current_row_idx - 1][current_col_idx - 1]
		lowerCamelCase					:      Optional[Any]          =   triangle[current_row_idx - 1][current_col_idx]
		lowerCamelCase					:      str          =   above_to_left_elt + above_to_right_elt
def 		UpperCAmelCase (		a_      ):





		'''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					:      list[list[int]]          =   [[1]]

		for row_index in range(1,						_lowerCamelCase      ):
				lowerCamelCase					:      Optional[int]          =   [0] + result[-1] + [0]
				lowerCamelCase					:      Tuple          =   row_index + 1
				# Calculate the number of distinct elements in a row
				lowerCamelCase					:      Tuple          =   sum(divmod(_lowerCamelCase,						2      )      )
				lowerCamelCase					:      Union[str, Any]          =   [
				    temp_row[i - 1] + temp_row[i] for i in range(1,						distinct_elements + 1      )
				]
				lowerCamelCase					:      List[Any]          =   row_first_half[: (row_index + 1) // 2]
				row_second_half.reverse()
				lowerCamelCase					:      Dict          =   row_first_half + row_second_half
				result.append(_lowerCamelCase      )

		return result
def 		UpperCAmelCase (		):





		'''simple docstring'''


		from collections.abc import Callable
		from timeit import timeit

		def benchmark_a_function(a_,						a_      ) -> None:
				lowerCamelCase					:      Tuple          =   F"""{func.__name__}({value})"""
				lowerCamelCase					:      str          =   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()








"""simple docstring"""

def 		UpperCAmelCase (		a_,						a_      ):





		'''simple docstring'''


		while b:
				lowerCamelCase     ,   lowerCamelCase					:      Tuple          =   b, a % b
		return a
def 		UpperCAmelCase (		a_,						a_      ):





		'''simple docstring'''


		return a if b == 0 else euclidean_gcd_recursive(a_,						a % b      )
def 		UpperCAmelCase (		):





		'''simple docstring'''


		print(F"""euclidean_gcd(3, 5) = {euclidean_gcd(3,						5      )}"""      )
		print(F"""euclidean_gcd(5, 3) = {euclidean_gcd(5,						3      )}"""      )
		print(F"""euclidean_gcd(1, 3) = {euclidean_gcd(1,						3      )}"""      )
		print(F"""euclidean_gcd(3, 6) = {euclidean_gcd(3,						6      )}"""      )
		print(F"""euclidean_gcd(6, 3) = {euclidean_gcd(6,						3      )}"""      )

		print(F"""euclidean_gcd_recursive(3, 5) = {euclidean_gcd_recursive(3,						5      )}"""      )
		print(F"""euclidean_gcd_recursive(5, 3) = {euclidean_gcd_recursive(5,						3      )}"""      )
		print(F"""euclidean_gcd_recursive(1, 3) = {euclidean_gcd_recursive(1,						3      )}"""      )
		print(F"""euclidean_gcd_recursive(3, 6) = {euclidean_gcd_recursive(3,						6      )}"""      )
		print(F"""euclidean_gcd_recursive(6, 3) = {euclidean_gcd_recursive(6,						3      )}"""      )


if __name__ == "__main__":
					main()






