


"""simple docstring"""







import math_equivalence  # From: git+https://github.com/hendrycks/math.git

import datasets


a__    :							Any            =					'''\
@article{hendrycksmath2021,
  title={Measuring Mathematical Problem Solving With the MATH Dataset},
  author={Dan Hendrycks
    and Collin Burns
    and Saurav Kadavath
    and Akul Arora
    and Steven Basart
    and Eric Tang
    and Dawn Song
    and Jacob Steinhardt},
  journal={arXiv preprint arXiv:2103.03874},
  year={2021}
}
'''


a__    :							Dict            =					'''\
This metric is used to assess performance on the Mathematics Aptitude Test of Heuristics (MATH) dataset.
It first canonicalizes the inputs (e.g., converting "1/2" to "\\frac{1}{2}") and then computes accuracy.
'''


a__    :							Optional[int]            =					r'''
Calculates accuracy after canonicalizing inputs.

Args:
    predictions: list of predictions to score. Each prediction
        is a string that contains natural language and LaTex.
    references: list of reference for each prediction. Each
        reference is a string that contains natural language
        and LaTex.
Returns:
    accuracy: accuracy after canonicalizing inputs
        (e.g., converting "1/2" to "\\frac{1}{2}")

Examples:
    >>> metric = datasets.load_metric("competition_math")
    >>> results = metric.compute(references=["\\frac{1}{2}"], predictions=["1/2"])
    >>> print(results)
    {\'accuracy\': 1.0}
'''




@datasets.utils.file_utils.add_end_docstrings(_DESCRIPTION      ,  _KWARGS_DESCRIPTION)
class 			UpperCamelCase_     (			datasets.Metric):

	"""simple docstring"""





	def   UpperCAmelCase_				(			self      :    Tuple       )	->     Optional[int]:
						return datasets.MetricInfo(
						    description=_DESCRIPTION      ,      citation=_CITATION      ,      inputs_description=_KWARGS_DESCRIPTION      ,      features=datasets.Features(
						        {
						            "predictions": datasets.Value("string"       ),
						            "references": datasets.Value("string"       ),
						        }       )      ,      homepage="https://github.com/hendrycks/math"      ,      codebase_urls=["https://github.com/hendrycks/math"]      ,      )




	def   UpperCAmelCase_				(			self      :    Dict      ,      UpperCAmelCase__      :    int      ,      UpperCAmelCase__      :    Optional[int]       )	->     Any:
						__SCREAMING_SNAKE_CASE						       =    0.0
						for i, j in zip(UpperCAmelCase__      ,      UpperCAmelCase__       ):
											n_correct += 1.0 if math_equivalence.is_equiv(UpperCAmelCase__      ,      UpperCAmelCase__       ) else 0.0
						__SCREAMING_SNAKE_CASE						       =    n_correct / len(UpperCAmelCase__       )
						return {
						    "accuracy": accuracy,
						}




"""simple docstring"""







a__    :							Optional[Any]            =					'''ABCDEFGHIJKLMNOPQRSTUVWXYZ'''




def        UpperCAmelCase__	():




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE						       =    input("Enter message: "       )
					__SCREAMING_SNAKE_CASE						       =    input("Enter key [alphanumeric]: "       )
					__SCREAMING_SNAKE_CASE						       =    input("Encrypt/Decrypt [e/d]: "       )

					if mode.lower().startswith("e"       ):
										__SCREAMING_SNAKE_CASE						       =    "encrypt"
										__SCREAMING_SNAKE_CASE						       =    encrypt_message(lowerCAmelCase_  ,						lowerCAmelCase_       )
					elif mode.lower().startswith("d"       ):
										__SCREAMING_SNAKE_CASE						       =    "decrypt"
										__SCREAMING_SNAKE_CASE						       =    decrypt_message(lowerCAmelCase_  ,						lowerCAmelCase_       )

					print(f"""\n{mode.title()}ed message:"""       )
					print(lowerCAmelCase_       )




def        UpperCAmelCase__	(lowerCAmelCase_  ,						lowerCAmelCase_       ):




					'''simple docstring'''


					return translate_message(lowerCAmelCase_  ,						lowerCAmelCase_  ,						"encrypt"       )




def        UpperCAmelCase__	(lowerCAmelCase_  ,						lowerCAmelCase_       ):




					'''simple docstring'''


					return translate_message(lowerCAmelCase_  ,						lowerCAmelCase_  ,						"decrypt"       )




def        UpperCAmelCase__	(lowerCAmelCase_  ,						lowerCAmelCase_  ,						lowerCAmelCase_       ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE						       =    []
					__SCREAMING_SNAKE_CASE						       =    0
					__SCREAMING_SNAKE_CASE						       =    key.upper()

					for symbol in message:
										__SCREAMING_SNAKE_CASE						       =    LETTERS.find(symbol.upper()       )
										if num != -1:
															if mode == "encrypt":
																				num += LETTERS.find(key[key_index]       )
															elif mode == "decrypt":
																				num -= LETTERS.find(key[key_index]       )

															num %= len(lowerCAmelCase_       )

															if symbol.isupper():
																				translated.append(LETTERS[num]       )
															elif symbol.islower():
																				translated.append(LETTERS[num].lower()       )

															key_index += 1
															if key_index == len(lowerCAmelCase_       ):
																				__SCREAMING_SNAKE_CASE						       =    0
										else:
															translated.append(lowerCAmelCase_       )
					return "".join(lowerCAmelCase_       )


if __name__ == "__main__":
		main()
