



'''simple docstring'''






import timeit



class 							lowercase :


 """simple docstring"""


 def __init__(							self						,a_							)	->     List[str]:
        if isinstance(a_						,a_							):  # Initializes a matrix identical to the one provided.
               _UpperCAmelCase						:		Optional[Any]      =				arg
               _UpperCAmelCase						:		List[Any]      =				len(a_							)
        else:  # Initializes a square matrix of the given size and set values to zero.
               _UpperCAmelCase						:		Optional[int]      =				arg
               _UpperCAmelCase						:		str      =				[[0 for _ in range(self.n							)] for _ in range(self.n							)]







 def __mul__(							self						,a_							)	->     int:
        _UpperCAmelCase						:		int      =				Matrix(self.n							)
        for i in range(self.n							):
               for j in range(self.n							):
                      for k in range(self.n							):
                             matrix.t[i][j] += self.t[i][k] * b.t[k][j]
        return matrix







def 					snake_case_      (  lowerCAmelCase_ ,     lowerCAmelCase_	)->	Any:





       '''simple docstring'''


       _UpperCAmelCase						:		List[Any]      =				Matrix([[1, 0], [0, 1]]	)
       while b > 0:
              if b & 1:
                     matrix *= a
              a *= a
              b >>= 1
       return matrix




def 					snake_case_      (  lowerCAmelCase_ ,     lowerCAmelCase_ ,     lowerCAmelCase_	)->	List[str]:





       '''simple docstring'''


       if n == 1:
              return fa
       elif n == 2:
              return fa
       _UpperCAmelCase						:		int      =				Matrix([[1, 1], [1, 0]]	)
       _UpperCAmelCase						:		int      =				modular_exponentiation(UpperCamelCase__ ,     n - 2	)
       return fa * matrix.t[0][0] + fa * matrix.t[0][1]




def 					snake_case_      (  lowerCAmelCase_ ,     lowerCAmelCase_ ,     lowerCAmelCase_	)->	List[Any]:





       '''simple docstring'''


       if n == 1:
              return fa
       elif n == 2:
              return fa

       _UpperCAmelCase						:		List[Any]      =				fa
       _UpperCAmelCase						:		int      =				fa
       n -= 2

       while n > 0:
              _UpperCAmelCase  ,_UpperCAmelCase						:		str      =				fn_a + fn_a, fn_a
              n -= 1

       return fn_a




def 					snake_case_      (  )->	Union[str, Any]:





       '''simple docstring'''


       _UpperCAmelCase						:		Optional[int]      =				"""\nfrom random import randint\nfrom __main__ import fibonacci_with_matrix_exponentiation\n"""
       _UpperCAmelCase						:		int      =				"""fibonacci_with_matrix_exponentiation(randint(1,70000), 1, 1)"""
       _UpperCAmelCase						:		List[str]      =				timeit.timeit(setup=UpperCamelCase__ ,     stmt=UpperCamelCase__ ,     number=100	)
       print("""With matrix exponentiation the average execution time is """ ,     exec_time / 100	)
       return exec_time




def 					snake_case_      (  )->	List[str]:





       '''simple docstring'''


       _UpperCAmelCase						:		Any      =				"""\nfrom random import randint\nfrom __main__ import simple_fibonacci\n"""
       _UpperCAmelCase						:		Any      =				"""simple_fibonacci(randint(1,70000), 1, 1)"""
       _UpperCAmelCase						:		Union[str, Any]      =				timeit.timeit(setup=UpperCamelCase__ ,     stmt=UpperCamelCase__ ,     number=100	)
       print(
           """Without matrix exponentiation the average execution time is """ ,     exec_time / 100	)
       return exec_time




def 					snake_case_      (  )->	Optional[int]:





       '''simple docstring'''


       matrix_exponentiation_time()
       simple_fibonacci_time()


if __name__ == "__main__":
   main()








'''simple docstring'''






from string import ascii_uppercase




def 					snake_case_      (  lowerCAmelCase_ ,     lowerCAmelCase_ ,     lowerCAmelCase_ = False ,     lowerCAmelCase_ = ascii_uppercase	)->	str:





       '''simple docstring'''


       _UpperCAmelCase						:		List[str]      =				keyword.upper()
       _UpperCAmelCase						:		Optional[int]      =				plaintext.upper()
       _UpperCAmelCase						:		Optional[int]      =				set(lowerCAmelCase_	)

       # create a list of unique characters in the keyword - their order matters
       # it determines how we will map plaintext characters to the ciphertext
       _UpperCAmelCase						:		str      =				[]
       for char in keyword:
              if char in alphabet_set and char not in unique_chars:
                     unique_chars.append(lowerCAmelCase_	)
    # the number of those unique characters will determine the number of rows
       _UpperCAmelCase						:		Optional[Any]      =				len(lowerCAmelCase_	)

       # create a shifted version of the alphabet
       _UpperCAmelCase						:		Optional[Any]      =				unique_chars + [
           char for char in alphabet if char not in unique_chars
       ]

       # create a modified alphabet by splitting the shifted alphabet into rows
       _UpperCAmelCase						:		List[str]      =				[
           shifted_alphabet[k : k + num_unique_chars_in_keyword]
           for k in range(0 ,     26 ,     lowerCAmelCase_	)
       ]

       # map the alphabet characters to the modified alphabet characters
       # going 'vertically' through the modified alphabet - consider columns first
       _UpperCAmelCase						:		int      =				{}
       _UpperCAmelCase						:		int      =				0
       for column in range(lowerCAmelCase_	):
              for row in modified_alphabet:
                     # if current row (the last one) is too short, break out of loop
                     if len(lowerCAmelCase_	) <= column:
                            break

                     # map current letter to letter in modified alphabet
                     _UpperCAmelCase						:		Optional[int]      =				row[column]
                     letter_index += 1

       if verbose:
              print(lowerCAmelCase_	)
       # create the encrypted text by mapping the plaintext to the modified alphabet
       return "".join(mapping[char] if char in mapping else char for char in plaintext	)


if __name__ == "__main__":
   # example use
   print(mixed_keyword("""college""", """UNIVERSITY"""))



