



"""simple docstring"""






import json
import os
from dataclasses import dataclass

import numpy as np
import pyarrow as pa

import datasets
from utils import get_duration


__UpperCAmelCase      :      str   					=					10_00_00_00_00_00
__UpperCAmelCase      :      Union[str, Any]   					=					1_00_00

__UpperCAmelCase					,	__UpperCAmelCase      :      Union[str, Any]   					=					os.path.split(__file__)
__UpperCAmelCase      :      Dict   					=					os.path.join(RESULTS_BASEPATH, 'results', RESULTS_FILENAME.replace('.py', '.json'))
def      A      (			_A,     _A							):




					"""simple docstring"""
					snake_case_						:Dict								=						pa.Table.from_pydict({"col": [0] * chunk_size}							)
					snake_case_						:str								=						pa.concat_tables([table] * (num_examples // chunk_size)							)
					return datasets.Dataset(_A,     fingerprint="table_100B"							)

@dataclass
class 	__lowerCAmelCase							:


					'''simple docstring'''


					a__        =     42
					a__        =     42
					a__        =     42
					a__        =     42







					def 		_a (      self   ):




										"""simple docstring"""





										snake_case_						:Union[str, Any]								=						np.random.default_rng(self.seed   )
										snake_case_						:str								=						rng.integers(low=self.low    ,       high=self.high    ,       size=self.size   ).tolist()







					def __iter__(      self   ):




										"""simple docstring"""





										return iter(self._sampled_values   )







					def __len__(      self   ):




										"""simple docstring"""





										return self.size



@get_duration
def      A      (			_A							):




					"""simple docstring"""
					snake_case_						:Any								=						dataset[0]
@get_duration
def      A      (			_A							):




					"""simple docstring"""
					snake_case_						:str								=						dataset[-1]
@get_duration
def      A      (			_A							):




					"""simple docstring"""
					snake_case_						:List[Any]								=						dataset[range(len(_A							) // 2,     len(_A							) // 2 + 1_024							)]
@get_duration
def      A      (			_A							):




					"""simple docstring"""
					snake_case_						:str								=						dataset[RandIter(0,     len(_A							),     1_024,     seed=42							)]
def      A      (			):




					"""simple docstring"""
					snake_case_						:Any								=						{"num examples": SPEED_TEST_N_EXAMPLES}
					snake_case_						:Tuple								=						(get_first_row, get_last_row, get_batch_of_aaaa_rows, get_batch_of_aaaa_random_rows)
					print("generating dataset"							)
					snake_case_						:List[str]								=						generate_100B_dataset(num_examples=_A,     chunk_size=_A							)
					print("Functions"							)
					for func in functions:
										print(func.__name__							)
										snake_case_						:Tuple								=						func(_A							)

					with open(_A,     "wb"							) as f:
										f.write(json.dumps(_A							).encode("utf-8"							)							)


if __name__ == "__main__":  # useful to run the profiler
				benchmark_table_100B()






"""simple docstring"""






def      A      (			_A,     _A							):




					"""simple docstring"""
					if not isinstance(_A,     _A							):
										raise TypeError("plaintext must be a string"							)
					if not isinstance(_A,     _A							):
										raise TypeError("key must be a string"							)

					if not plaintext:
										raise ValueError("plaintext is empty"							)
					if not key:
										raise ValueError("key is empty"							)

					key += plaintext
					snake_case_						:Optional[int]								=						plaintext.lower()
					snake_case_						:Union[str, Any]								=						key.lower()
					snake_case_						:Any								=						0
					snake_case_						:str								=						0
					snake_case_						:Union[str, Any]								=						""
					while plaintext_iterator < len(_A							):
										if (
										    ord(plaintext[plaintext_iterator]							) < 97
										    or ord(plaintext[plaintext_iterator]							) > 122
										):
															ciphertext += plaintext[plaintext_iterator]
															plaintext_iterator += 1
										elif ord(key[key_iterator]							) < 97 or ord(key[key_iterator]							) > 122:
															key_iterator += 1
										else:
															ciphertext += chr(
															    (
															        (ord(plaintext[plaintext_iterator]							) - 97 + ord(key[key_iterator]							))
															        - 97
															    )
															    % 26
															    + 97							)
															key_iterator += 1
															plaintext_iterator += 1
					return ciphertext
def      A      (			_A,     _A							):




					"""simple docstring"""
					if not isinstance(_A,     _A							):
										raise TypeError("ciphertext must be a string"							)
					if not isinstance(_A,     _A							):
										raise TypeError("key must be a string"							)

					if not ciphertext:
										raise ValueError("ciphertext is empty"							)
					if not key:
										raise ValueError("key is empty"							)

					snake_case_						:Tuple								=						key.lower()
					snake_case_						:Tuple								=						0
					snake_case_						:int								=						0
					snake_case_						:int								=						""
					while ciphertext_iterator < len(_A							):
										if (
										    ord(ciphertext[ciphertext_iterator]							) < 97
										    or ord(ciphertext[ciphertext_iterator]							) > 122
										):
															plaintext += ciphertext[ciphertext_iterator]
										else:
															plaintext += chr(
															    (ord(ciphertext[ciphertext_iterator]							) - ord(key[key_iterator]							)) % 26
															    + 97							)
															key += chr(
															    (ord(ciphertext[ciphertext_iterator]							) - ord(key[key_iterator]							)) % 26
															    + 97							)
															key_iterator += 1
										ciphertext_iterator += 1
					return plaintext


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				__UpperCAmelCase      :      Dict   					=					int(input('Type 1 to encrypt or 2 to decrypt:'))
				if operation == 1:
								__UpperCAmelCase      :      List[str]   					=					input('Typeplaintext to be encrypted:\n')
								__UpperCAmelCase      :      Optional[int]   					=					input('Type the key:\n')
								print(encrypt(plaintext, key))
				elif operation == 2:
								__UpperCAmelCase      :      List[Any]   					=					input('Type the ciphertext to be decrypted:\n')
								__UpperCAmelCase      :      Dict   					=					input('Type the key:\n')
								print(decrypt(ciphertext, key))
				decrypt('jsqqs avvwo', 'coffee')

