"""simple docstring"""




import timeit

import numpy as np

import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD





def 							SCREAMING_SNAKE_CASE					(      _lowerCamelCase						:	List[Any]     )	->				Tuple:


		def wrapper(*_lowerCamelCase						:	int      ,**_lowerCamelCase						:	List[str]     ):
				_lowerCAmelCase						:	Any        =					timeit.default_timer()
				_lowerCAmelCase						:	Tuple        =					func(*SCREAMING_SNAKE_CASE__      ,**SCREAMING_SNAKE_CASE__     )
				_lowerCAmelCase						:	str        =					timeit.default_timer() - starttime
				return delta

		_lowerCAmelCase						:	Tuple        =					func.__name__

		return wrapper





def 							SCREAMING_SNAKE_CASE					(      _lowerCamelCase						:	Optional[Any]      ,_lowerCamelCase						:	Tuple=100      ,_lowerCamelCase						:	Optional[int]=None     )	->				str:
		_lowerCAmelCase						:	Dict        =					[]
		_lowerCAmelCase						:	int        =					seq_shapes or {}
		for i in range(SCREAMING_SNAKE_CASE__     ):
				_lowerCAmelCase						:	Optional[int]        =					{}
				for col_id, (k, v) in enumerate(features.items()     ):
						if isinstance(SCREAMING_SNAKE_CASE__      ,_ArrayXD     ):
								_lowerCAmelCase						:	Tuple        =					np.random.rand(*v.shape     ).astype(v.dtype     )
						elif isinstance(SCREAMING_SNAKE_CASE__      ,datasets.Value     ):
								if v.dtype == "string":
										_lowerCAmelCase						:	Dict        =					'''The small grey turtle was surprisingly fast when challenged.'''
								else:
										_lowerCAmelCase						:	List[str]        =					np.random.randint(10      ,size=1     ).astype(v.dtype     ).item()
						elif isinstance(SCREAMING_SNAKE_CASE__      ,datasets.Sequence     ):
								while isinstance(SCREAMING_SNAKE_CASE__      ,datasets.Sequence     ):
										_lowerCAmelCase						:	Union[str, Any]        =					v.feature
								_lowerCAmelCase						:	List[str]        =					seq_shapes[k]
								_lowerCAmelCase						:	Any        =					np.random.rand(*SCREAMING_SNAKE_CASE__     ).astype(v.dtype     )
						_lowerCAmelCase						:	Dict        =					data

				dummy_data.append((i, example)     )

		return dummy_data






def 							SCREAMING_SNAKE_CASE					(      _lowerCamelCase						:	Union[str, Any]      ,_lowerCamelCase						:	Optional[int]      ,_lowerCamelCase						:	Tuple=100      ,_lowerCamelCase						:	Any=None     )	->				Any:
		_lowerCAmelCase						:	Tuple        =					generate_examples(SCREAMING_SNAKE_CASE__      ,num_examples=SCREAMING_SNAKE_CASE__      ,seq_shapes=SCREAMING_SNAKE_CASE__     )

		with ArrowWriter(features=SCREAMING_SNAKE_CASE__      ,path=SCREAMING_SNAKE_CASE__     ) as writer:
				for key, record in dummy_data:
						_lowerCAmelCase						:	Dict        =					features.encode_example(SCREAMING_SNAKE_CASE__     )
						writer.write(SCREAMING_SNAKE_CASE__     )

				_lowerCAmelCase						:	List[str]        =					writer.finalize()

		if not num_final_examples == num_examples:
				raise ValueError(
				    f"Error writing the dataset, wrote {num_final_examples} examples but should have written {num_examples}."     )

		_lowerCAmelCase						:	int        =					datasets.Dataset.from_file(filename=SCREAMING_SNAKE_CASE__      ,info=datasets.DatasetInfo(features=SCREAMING_SNAKE_CASE__     )     )

		return dataset





"""simple docstring"""




import math





def 							SCREAMING_SNAKE_CASE					(      )	->				None:
  _lowerCAmelCase						:	Any        =					input("""Enter message: """     )
  _lowerCAmelCase						:	List[Any]        =					int(input(f"Enter key [2-{len(_lowerCamelCase     ) - 1}]: "     )     )
  _lowerCAmelCase						:	Optional[Any]        =					input("""Encryption/Decryption [e/d]: """     )

  if mode.lower().startswith("""e"""     ):
    _lowerCAmelCase						:	Tuple        =					encrypt_message(_lowerCamelCase      ,_lowerCamelCase     )
  elif mode.lower().startswith("""d"""     ):
    _lowerCAmelCase						:	Dict        =					decrypt_message(_lowerCamelCase      ,_lowerCamelCase     )

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





def 							SCREAMING_SNAKE_CASE					(      _lowerCamelCase						:	int      ,_lowerCamelCase						:	str     )	->				str:
  _lowerCAmelCase						:	Dict        =					[""""""] * key
  for col in range(_lowerCamelCase     ):
    _lowerCAmelCase						:	List[str]        =					col
    while pointer < len(_lowerCamelCase     ):
      cipher_text[col] += message[pointer]
      pointer += key
  return "".join(_lowerCamelCase     )





def 							SCREAMING_SNAKE_CASE					(      _lowerCamelCase						:	int      ,_lowerCamelCase						:	str     )	->				str:
  _lowerCAmelCase						:	str        =					math.ceil(len(_lowerCamelCase     ) / key     )
  _lowerCAmelCase						:	Union[str, Any]        =					key
  _lowerCAmelCase						:	Any        =					(num_cols * num_rows) - len(_lowerCamelCase     )
  _lowerCAmelCase						:	Dict        =					[""""""] * num_cols
  _lowerCAmelCase						:	Optional[Any]        =					0
  _lowerCAmelCase						:	Dict        =					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						:	str        =					0
      row += 1

  return "".join(_lowerCamelCase     )


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     main()




