





"""simple docstring"""




from __future__ import annotations

import queue
class SCREAMING_SNAKE_CASE_  :






						def __init__( self : Any						,				_A : Union[str, Any]		)							->      List[Any]:







							"""simple docstring"""


							snake_case_						:     List[str]     =		data
							snake_case_						:     int     =		None
							snake_case_						:     Any     =		None


def 							SCREAMING_SNAKE_CASE__  (      ):
	print('\n********Press N to stop entering at any point of time********\n'				)
	snake_case_						:     Optional[int]     =		input('Enter the value of the root node: '				).strip().lower()
	snake_case_						:     int     =		queue.Queue()
	snake_case_						:     Union[str, Any]     =		TreeNode(int(__a				)				)
	q.put(__a				)
	while not q.empty():
		snake_case_						:     Dict     =		q.get()
		snake_case_						:     Optional[Any]     =		f"""Enter the left node of {node_found.data}: """
		snake_case_						:     Optional[int]     =		input(__a				).strip().lower() or 'n'
		if check == "n":
			return tree_node
		snake_case_						:     Optional[int]     =		TreeNode(int(__a				)				)
		snake_case_						:     Any     =		left_node
		q.put(__a				)
		snake_case_						:     Optional[Any]     =		f"""Enter the right node of {node_found.data}: """
		snake_case_						:     int     =		input(__a				).strip().lower() or 'n'
		if check == "n":
			return tree_node
		snake_case_						:     Any     =		TreeNode(int(__a				)				)
		snake_case_						:     int     =		right_node
		q.put(__a				)
	raise


def 							SCREAMING_SNAKE_CASE__  (      __a				):





	if not isinstance(__a				,	__a				) or not node:
		return
	print(node.data				,	end=','				)
	pre_order(node.left				)
	pre_order(node.right				)


def 							SCREAMING_SNAKE_CASE__  (      __a				):





	if not isinstance(__a				,	__a				) or not node:
		return
	in_order(node.left				)
	print(node.data				,	end=','				)
	in_order(node.right				)


def 							SCREAMING_SNAKE_CASE__  (      __a				):





	if not isinstance(__a				,	__a				) or not node:
		return
	post_order(node.left				)
	post_order(node.right				)
	print(node.data				,	end=','				)


def 							SCREAMING_SNAKE_CASE__  (      __a				):





	if not isinstance(__a				,	__a				) or not node:
		return
	snake_case_						:     Dict     =		queue.Queue()
	q.put(__a				)
	while not q.empty():
		snake_case_						:     Any     =		q.get()
		print(node_dequeued.data				,	end=','				)
		if node_dequeued.left:
			q.put(node_dequeued.left				)
		if node_dequeued.right:
			q.put(node_dequeued.right				)


def 							SCREAMING_SNAKE_CASE__  (      __a				):





	if not isinstance(__a				,	__a				) or not node:
		return
	snake_case_						:     List[Any]     =		queue.Queue()
	q.put(__a				)
	while not q.empty():
		snake_case_						:     str     =		[]
		while not q.empty():
			snake_case_						:     List[Any]     =		q.get()
			print(node_dequeued.data				,	end=','				)
			if node_dequeued.left:
				list_.append(node_dequeued.left				)
			if node_dequeued.right:
				list_.append(node_dequeued.right				)
		print()
		for node in list_:
			q.put(__a				)


def 							SCREAMING_SNAKE_CASE__  (      __a				):





	if not isinstance(__a				,	__a				) or not node:
		return
	snake_case_						:     int     =		[]
	snake_case_						:     Optional[Any]     =		node
	while n or stack:
		while n:  # start from root node, find its left child
			print(n.data				,	end=','				)
			stack.append(__a				)
			snake_case_						:     int     =		n.left
		# end of while means current node doesn't have left child
		snake_case_						:     Union[str, Any]     =		stack.pop()
		# start to traverse its right child
		snake_case_						:     str     =		n.right


def 							SCREAMING_SNAKE_CASE__  (      __a				):





	if not isinstance(__a				,	__a				) or not node:
		return
	snake_case_						:     Dict     =		[]
	snake_case_						:     int     =		node
	while n or stack:
		while n:
			stack.append(__a				)
			snake_case_						:     str     =		n.left
		snake_case_						:     Any     =		stack.pop()
		print(n.data				,	end=','				)
		snake_case_						:     Dict     =		n.right


def 							SCREAMING_SNAKE_CASE__  (      __a				):





	if not isinstance(__a				,	__a				) or not node:
		return
	snake_case_  ,snake_case_						:     List[str]     =		[], []
	snake_case_						:     List[str]     =		node
	stacka.append(__a				)
	while stacka:  # to find the reversed order of post order, store it in stack2
		snake_case_						:     Optional[Any]     =		stacka.pop()
		if n.left:
			stacka.append(n.left				)
		if n.right:
			stacka.append(n.right				)
		stacka.append(__a				)
	while stacka:  # pop up from stack2 will be the post order
		print(stacka.pop().data				,	end=','				)


def 							SCREAMING_SNAKE_CASE__  (      __a = ""				,	__a=50				,	__a="*"				):





	if not s:
		return "\n" + width * char
	snake_case_  ,snake_case_						:     Optional[Any]     =		divmod(width - len(__a				) - 2				,	2				)
	return f"""{left * char} {s} {(left + extra) * char}"""


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						print(prompt("""Binary Tree Traversals"""))

						_SCREAMING_SNAKE_CASE 		=						build_tree()
						print(prompt("""Pre Order Traversal"""))
						pre_order(node)
						print(prompt() + """\n""")

						print(prompt("""In Order Traversal"""))
						in_order(node)
						print(prompt() + """\n""")

						print(prompt("""Post Order Traversal"""))
						post_order(node)
						print(prompt() + """\n""")

						print(prompt("""Level Order Traversal"""))
						level_order(node)
						print(prompt() + """\n""")

						print(prompt("""Actual Level Order Traversal"""))
						level_order_actual(node)
						print("""*""" * 50 + """\n""")

						print(prompt("""Pre Order Traversal - Iteration Version"""))
						pre_order_iter(node)
						print(prompt() + """\n""")

						print(prompt("""In Order Traversal - Iteration Version"""))
						in_order_iter(node)
						print(prompt() + """\n""")

						print(prompt("""Post Order Traversal - Iteration Version"""))
						post_order_iter(node)
						print(prompt())








import re
import string

import numpy as np

import datasets


_SCREAMING_SNAKE_CASE 		=						"""
Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.
"""

_SCREAMING_SNAKE_CASE 		=						"""
Args:
    predictions: List of predicted texts.
    references: List of reference texts.
    regexes_to_ignore: List, defaults to None. Regex expressions of characters to
        ignore when calculating the exact matches. Note: these regexes are removed
        from the input data before the changes based on the options below (e.g. ignore_case,
        ignore_punctuation, ignore_numbers) are applied.
    ignore_case: Boolean, defaults to False. If true, turns everything
        to lowercase so that capitalization differences are ignored.
    ignore_punctuation: Boolean, defaults to False. If true, removes all punctuation before
        comparing predictions and references.
    ignore_numbers: Boolean, defaults to False. If true, removes all punctuation before
        comparing predictions and references.
Returns:
    exact_match: Dictionary containing exact_match rate. Possible values are between 0.0 and 100.0, inclusive.
Examples:
    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds)
    >>> print(round(results[\"exact_match\"], 1))
    25.0

    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=[\"the \", \"yell\"], ignore_case=True, ignore_punctuation=True)
    >>> print(round(results[\"exact_match\"], 1))
    50.0


    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=[\"the \", \"yell\", \"YELL\"], ignore_case=True, ignore_punctuation=True)
    >>> print(round(results[\"exact_match\"], 1))
    75.0

    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=[\"the \", \"yell\", \"YELL\"], ignore_case=True, ignore_punctuation=True, ignore_numbers=True)
    >>> print(round(results[\"exact_match\"], 1))
    100.0

    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"The cat sat on the mat.\", \"Theaters are great.\", \"It's like comparing oranges and apples.\"]
    >>> preds = [\"The cat sat on the mat?\", \"Theaters are great.\", \"It's like comparing apples and oranges.\"]
    >>> results = exact_match.compute(references=refs, predictions=preds)
    >>> print(round(results[\"exact_match\"], 1))
    33.3

"""

_SCREAMING_SNAKE_CASE 		=						"""
"""
@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION    ,			_KWARGS_DESCRIPTION   )
class SCREAMING_SNAKE_CASE_  (   datasets.Metric   ):






						def UpperCAmelCase_			( self : Union[str, Any]		)							->      Optional[Any]:







							"""simple docstring"""


							return datasets.MetricInfo(
							    description=_DESCRIPTION						,				citation=_CITATION						,				inputs_description=_KWARGS_DESCRIPTION						,				features=datasets.Features(
							        {
							            'predictions': datasets.Value('string'						,				id='sequence'		),
							            'references': datasets.Value('string'						,				id='sequence'		),
							        }		)						,				reference_urls=[]						,				)






						def UpperCAmelCase_			( self : List[Any]						,				_A : Optional[Any]						,				_A : Optional[int]						,				_A : Optional[int]=None						,				_A : Dict=False						,				_A : Dict=False						,				_A : Optional[Any]=False						,				)							->      List[str]:







							"""simple docstring"""


							if regexes_to_ignore is not None:
								for s in regexes_to_ignore:
									snake_case_						:     List[str]     =		np.array([re.sub(_A						,				''						,				_A		) for x in predictions]		)
									snake_case_						:     int     =		np.array([re.sub(_A						,				''						,				_A		) for x in references]		)
							else:
								snake_case_						:     Optional[Any]     =		np.asarray(_A		)
								snake_case_						:     Optional[Any]     =		np.asarray(_A		)

							if ignore_case:
								snake_case_						:     int     =		np.char.lower(_A		)
								snake_case_						:     List[str]     =		np.char.lower(_A		)

							if ignore_punctuation:
								snake_case_						:     str     =		string.punctuation.maketrans(''						,				''						,				string.punctuation		)
								snake_case_						:     str     =		np.char.translate(_A						,				table=_A		)
								snake_case_						:     Any     =		np.char.translate(_A						,				table=_A		)

							if ignore_numbers:
								snake_case_						:     int     =		string.digits.maketrans(''						,				''						,				string.digits		)
								snake_case_						:     Tuple     =		np.char.translate(_A						,				table=_A		)
								snake_case_						:     Optional[Any]     =		np.char.translate(_A						,				table=_A		)

							snake_case_						:     Optional[Any]     =		predictions == references

							return {"exact_match": np.mean(_A		) * 100}

