






"""simple docstring"""


from __future__ import annotations

from collections.abc import Generator




def 				a (     UpperCamelCase_							:				int		)  ->		Generator[int, None, None]:
 if not isinstance(UpperCamelCase_     ,	UpperCamelCase_		) or n < 1:
  raise Exception('Sequence only defined for positive integers'		)

 yield n
 while n != 1:
  if n % 2 == 0:
   n //= 2
  else:
   __A	:       Optional[Any]       =	3 * n + 1
  yield n




def 				a (     )  ->		Optional[Any]:
 __A	:       List[str]       =	4_3
 __A	:       List[str]       =	tuple(collatz_sequence(UpperCamelCase_		)		)
 print(UpperCamelCase_		)
 print(F"Collatz sequence from {n} took {len(UpperCamelCase_		)} steps."		)


if __name__ == "__main__":
   main()













"""simple docstring"""


from string import ascii_uppercase




def 				a (     UpperCamelCase_							:				str     ,	UpperCamelCase_							:				str     ,	UpperCamelCase_							:				bool = False     ,	UpperCamelCase_							:				str = ascii_uppercase		)  ->		str:
 __A	:       List[str]       =	keyword.upper()
 __A	:       str       =	plaintext.upper()
 __A	:       int       =	set(UpperCamelCase_		)

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

 # create a shifted version of the alphabet
 __A	:       str       =	unique_chars + [
     char for char in alphabet if char not in unique_chars
 ]

 # create a modified alphabet by splitting the shifted alphabet into rows
 __A	:       int       =	[
     shifted_alphabet[k : k + num_unique_chars_in_keyword]
     for k in range(0     ,	2_6     ,	UpperCamelCase_		)
 ]

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

   # map current letter to letter in modified alphabet
   __A	:       str       =	row[column]
   letter_index += 1

 if verbose:
  print(UpperCamelCase_		)
 # 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"""))





