






'''simple docstring'''

def     __lowercase  (_lowercase     )   ->     None:


     """simple docstring"""
     __lowerCamelCase						:       List[Any]				   =				generate_pascal_triangle(_lowercase     )
     for row_idx in range(_lowercase     ):
          # 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     __lowercase  (_lowercase     )   ->     list[list[int]]:


     """simple docstring"""

     if not isinstance(_lowercase,						_lowercase     ):
          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(_lowercase     ):
          __lowerCamelCase						:       List[str]				   =				populate_current_row(_lowercase,						_lowercase     )
          triangle.append(_lowercase     )
     return triangle
def     __lowercase  (_lowercase,						_lowercase     )   ->     list[int]:


     """simple docstring"""
     __lowerCamelCase						:       Optional[int]				   =				[-1] * (current_row_idx + 1)
     # first and last elements of current row are equal to 1
     __lowerCamelCase   ,      __lowerCamelCase						:       Dict				   =				1, 1
     for current_col_idx in range(1,						_lowercase     ):
          calculate_current_element(
              _lowercase,						_lowercase,						_lowercase,						_lowercase     )
     return current_row
def     __lowercase  (_lowercase,						_lowercase,						_lowercase,						_lowercase,						)   ->     None:


     """simple docstring"""
     __lowerCamelCase						:       List[str]				   =				triangle[current_row_idx - 1][current_col_idx - 1]
     __lowerCamelCase						:       Any				   =				triangle[current_row_idx - 1][current_col_idx]
     __lowerCamelCase						:       List[str]				   =				above_to_left_elt + above_to_right_elt
def     __lowercase  (_lowercase     )   ->     list[list[int]]:


     """simple docstring"""

     if not isinstance(_lowercase,						_lowercase     ):
          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,						_lowercase     ):
          __lowerCamelCase						:       Dict				   =				[0] + result[-1] + [0]
          __lowerCamelCase						:       Tuple				   =				row_index + 1
          # Calculate the number of distinct elements in a row
          __lowerCamelCase						:       Tuple				   =				sum(divmod(_lowercase,						2     )     )
          __lowerCamelCase						:       Optional[int]				   =				[
              temp_row[i - 1] + temp_row[i] for i in range(1,						distinct_elements + 1     )
          ]
          __lowerCamelCase						:       str				   =				row_first_half[: (row_index + 1) // 2]
          row_second_half.reverse()
          __lowerCamelCase						:       Optional[Any]				   =				row_first_half + row_second_half
          result.append(_lowercase     )

     return result
def     __lowercase  ()   ->     None:


     """simple docstring"""
     from collections.abc import Callable
     from timeit import timeit

     def benchmark_a_function(_lowercase,						_lowercase     ) -> None:
          __lowerCamelCase						:       Union[str, Any]				   =				f"{func.__name__}({value})"
          __lowerCamelCase						:       Any				   =				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(_lowercase,						_lowercase     )
          print()


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   benchmark()











'''simple docstring'''

import math
def     __lowercase  ()   ->     None:


     """simple docstring"""
     __lowerCamelCase						:       Optional[int]				   =				input("""Enter message: """     )
     __lowerCamelCase						:       Optional[Any]				   =				int(input(f"Enter key [2-{len(_lowercase     ) - 1}]: "     )     )
     __lowerCamelCase						:       Dict				   =				input("""Encryption/Decryption [e/d]: """     )

     if mode.lower().startswith("""e"""     ):
          __lowerCamelCase						:       Any				   =				encrypt_message(_lowercase,						_lowercase     )
     elif mode.lower().startswith("""d"""     ):
          __lowerCamelCase						:       int				   =				decrypt_message(_lowercase,						_lowercase     )

     # Append pipe symbol (vertical bar) to identify spaces at the end.
     print(f"Output:\n{text + '|'}"     )
def     __lowercase  (_lowercase,						_lowercase     )   ->     str:


     """simple docstring"""
     __lowerCamelCase						:       int				   =				[""""""] * key
     for col in range(_lowercase     ):
          __lowerCamelCase						:       Optional[Any]				   =				col
          while pointer < len(_lowercase     ):
               cipher_text[col] += message[pointer]
               pointer += key
     return "".join(_lowercase     )
def     __lowercase  (_lowercase,						_lowercase     )   ->     str:


     """simple docstring"""
     __lowerCamelCase						:       List[str]				   =				math.ceil(len(_lowercase     ) / key     )
     __lowerCamelCase						:       List[str]				   =				key
     __lowerCamelCase						:       Tuple				   =				(num_cols * num_rows) - len(_lowercase     )
     __lowerCamelCase						:       List[str]				   =				[""""""] * num_cols
     __lowerCamelCase						:       List[str]				   =				0
     __lowerCamelCase						:       List[Any]				   =				0

     for symbol in message:
          plain_text[col] += symbol
          col += 1

          if (
              (col == num_cols)
              or (col == num_cols - 1)
              and (row >= num_rows - num_shaded_boxes)
          ):
               __lowerCamelCase						:       int				   =				0
               row += 1

     return "".join(_lowercase     )


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   main()



