



import itertools
import string
from collections.abc import Generator, Iterable






def        A       (      _lowerCamelCase       ,				_lowerCamelCase						):





							'''simple docstring'''




							_lowerCAmelCase  :							Tuple				     =					iter(_lowerCamelCase						)
							while True:
														_lowerCAmelCase  :							Dict				     =					tuple(itertools.islice(_lowerCamelCase       ,				_lowerCamelCase						)						)
														if not chunk:
																					return
														yield chunk






def        A       (      _lowerCamelCase						):





							'''simple docstring'''




							_lowerCAmelCase  :							Any				     =					"".join([c.upper() for c in dirty if c in string.ascii_letters]						)
							_lowerCAmelCase  :							Dict				     =					""

							if len(_lowerCamelCase						) < 2:
														return dirty

							for i in range(len(_lowerCamelCase						) - 1						):
														clean += dirty[i]

														if dirty[i] == dirty[i + 1]:
																					clean += "X"

							clean += dirty[-1]

							if len(_lowerCamelCase						) & 1:
														clean += "X"

							return clean






def        A       (      _lowerCamelCase						):





							'''simple docstring'''




							_lowerCAmelCase  :							List[Any]				     =					"ABCDEFGHIKLMNOPQRSTUVWXYZ"
							# we're using a list instead of a '2d' array because it makes the math
							# for setting up the table and doing the actual encoding/decoding simpler
							_lowerCAmelCase  :							int				     =					[]

							# copy key chars into the table if they are in `alphabet` ignoring duplicates
							for char in key.upper():
														if char not in table and char in alphabet:
																					table.append(_lowerCamelCase						)

    # fill the rest of the table in with the remaining alphabet chars
							for char in alphabet:
														if char not in table:
																					table.append(_lowerCamelCase						)

							return table






def        A       (      _lowerCamelCase       ,				_lowerCamelCase						):





							'''simple docstring'''




							_lowerCAmelCase  :							Dict				     =					generate_table(_lowerCamelCase						)
							_lowerCAmelCase  :							Union[str, Any]				     =					prepare_input(_lowerCamelCase						)
							_lowerCAmelCase  :							Any				     =					""

							# https://en.wikipedia.org/wiki/Playfair_cipher#Description
							for chara, chara in chunker(_lowerCamelCase       ,				2						):
														_lowerCAmelCase     ,					_lowerCAmelCase  :							str				     =					divmod(table.index(_lowerCamelCase						)       ,				5						)
														_lowerCAmelCase     ,					_lowerCAmelCase  :							Optional[int]				     =					divmod(table.index(_lowerCamelCase						)       ,				5						)

														if rowa == rowa:
																					ciphertext += table[rowa * 5 + (cola + 1) % 5]
																					ciphertext += table[rowa * 5 + (cola + 1) % 5]
														elif cola == cola:
																					ciphertext += table[((rowa + 1) % 5) * 5 + cola]
																					ciphertext += table[((rowa + 1) % 5) * 5 + cola]
														else:  # rectangle
																					ciphertext += table[rowa * 5 + cola]
																					ciphertext += table[rowa * 5 + cola]

							return ciphertext






def        A       (      _lowerCamelCase       ,				_lowerCamelCase						):





							'''simple docstring'''




							_lowerCAmelCase  :							Optional[int]				     =					generate_table(_lowerCamelCase						)
							_lowerCAmelCase  :							Tuple				     =					""

							# https://en.wikipedia.org/wiki/Playfair_cipher#Description
							for chara, chara in chunker(_lowerCamelCase       ,				2						):
														_lowerCAmelCase     ,					_lowerCAmelCase  :							str				     =					divmod(table.index(_lowerCamelCase						)       ,				5						)
														_lowerCAmelCase     ,					_lowerCAmelCase  :							Optional[Any]				     =					divmod(table.index(_lowerCamelCase						)       ,				5						)

														if rowa == rowa:
																					plaintext += table[rowa * 5 + (cola - 1) % 5]
																					plaintext += table[rowa * 5 + (cola - 1) % 5]
														elif cola == cola:
																					plaintext += table[((rowa - 1) % 5) * 5 + cola]
																					plaintext += table[((rowa - 1) % 5) * 5 + cola]
														else:  # rectangle
																					plaintext += table[rowa * 5 + cola]
																					plaintext += table[rowa * 5 + cola]

							return plaintext





def        A       (      _lowerCamelCase						):





							'''simple docstring'''




							if length <= 0 or not isinstance(_lowerCamelCase       ,				_lowerCamelCase						):
														raise ValueError("Length must be a positive integer."						)
							return [n * (2 * n - 1) for n in range(_lowerCamelCase						)]


if __name__ == "__main__":
						print(hexagonal_numbers(length=5))
						print(hexagonal_numbers(length=10))
