



from __future__ import annotations

import os

class 						UpperCAmelCase__     :




			'''simple docstring'''






			UpperCamelCase     		=			(
			    """High card""",
			    """One pair""",
			    """Two pairs""",
			    """Three of a kind""",
			    """Straight""",
			    """Flush""",
			    """Full house""",
			    """Four of a kind""",
			    """Straight flush""",
			    """Royal flush""",
			)

			UpperCamelCase     		=			(
			    """""",  # placeholder as tuples are zero-indexed
			    """One""",
			    """Two""",
			    """Three""",
			    """Four""",
			    """Five""",
			    """Six""",
			    """Seven""",
			    """Eight""",
			    """Nine""",
			    """Ten""",
			    """Jack""",
			    """Queen""",
			    """King""",
			    """Ace""",
			)




			def __init__(  self				:					Union[str, Any]			,			a_				:					str					):
					'''simple docstring'''





					if not isinstance(a_			,			a_					):
							__UpperCAmelCase       :	int						=      F'Hand should be of type \'str\': {hand!r}'
							raise TypeError(a_					)
					# split removes duplicate whitespaces so no need of strip
					if len(hand.split(''' '''					)					) != 5:
							__UpperCAmelCase       :	Optional[int]						=      F'Hand should contain only 5 cards: {hand!r}'
							raise ValueError(a_					)
					__UpperCAmelCase       :	List[str]						=      hand
					__UpperCAmelCase       :	Union[str, Any]						=      0
					__UpperCAmelCase       :	List[Any]						=      0
					__UpperCAmelCase				,   __UpperCAmelCase       :	int						=      self._internal_state()
					__UpperCAmelCase       :	Optional[Any]						=      self._get_hand_type()
					__UpperCAmelCase       :	Any						=      self._card_values[0]




			@property
			def 					snake_case__	(  self				:					Any					):
					'''simple docstring'''





					return self._hand




			def 					snake_case__	(  self				:					Optional[int]			,			a_				:					PokerHand					):
					'''simple docstring'''





					if self._hand_type > other._hand_type:
							return "Win"
					elif self._hand_type < other._hand_type:
							return "Loss"
					elif self._first_pair == other._first_pair:
							if self._second_pair == other._second_pair:
									return self._compare_cards(a_					)
							else:
									return "Win" if self._second_pair > other._second_pair else "Loss"
					return "Win" if self._first_pair > other._first_pair else "Loss"




			def 					snake_case__	(  self				:					Optional[Any]					):
					'''simple docstring'''





					__UpperCAmelCase       :	List[str]						=      PokerHand._HAND_NAME[self._hand_type - 14]
					__UpperCAmelCase       :	Tuple						=      PokerHand._CARD_NAME[self._high_card]
					__UpperCAmelCase       :	int						=      PokerHand._CARD_NAME[self._first_pair]
					__UpperCAmelCase       :	List[Any]						=      PokerHand._CARD_NAME[self._second_pair]
					if self._hand_type in [22, 19, 18]:
							return name + F', {high}-high'
					elif self._hand_type in [21, 17, 15]:
							return name + F', {paira}s'
					elif self._hand_type in [20, 16]:
							__UpperCAmelCase       :	List[str]						=      '''over''' if self._hand_type == 20 else '''and'''
							return name + F', {paira}s {join} {paira}s'
					elif self._hand_type == 23:
							return name
					else:
							return name + F', {high}'




			def 					snake_case__	(  self				:					Tuple			,			a_				:					PokerHand					):
					'''simple docstring'''





					for index, card_value in enumerate(self._card_values					):
							if card_value != other._card_values[index]:
									return "Win" if card_value > other._card_values[index] else "Loss"
					return "Tie"




			def 					snake_case__	(  self				:					List[Any]					):
					'''simple docstring'''





					if self._is_flush():
							if self._is_five_high_straight() or self._is_straight():
									return 23 if sum(self._card_values					) == 60 else 22
							return 19
					elif self._is_five_high_straight() or self._is_straight():
							return 18
					return 14 + self._is_same_kind()




			def 					snake_case__	(  self				:					str					):
					'''simple docstring'''





					return len(self._card_suit					) == 1




			def 					snake_case__	(  self				:					Dict					):
					'''simple docstring'''





					if sorted(self._card_values					) == [2, 3, 4, 5, 14]:
							if self._card_values[0] == 14:
									# Remember, our list is sorted in reverse order
									__UpperCAmelCase       :	int						=      self._card_values.pop(0					)
									self._card_values.append(a_					)
							return True
					return False




			def 					snake_case__	(  self				:					Optional[Any]					):
					'''simple docstring'''





					for i in range(4					):
							if self._card_values[i] - self._card_values[i + 1] != 1:
									return False
					return True




			def 					snake_case__	(  self				:					Tuple					):
					'''simple docstring'''





					__UpperCAmelCase       :	int						=      0
					for i in range(4					):
							# Compare two cards at a time, if they are same increase 'kind',
							# add the value of the card to val1, if it is repeating again we
							# will add 2 to 'kind' as there are now 3 cards with same value.
							# If we get card of different value than val1, we will do the same
							# thing with val2
							if self._card_values[i] == self._card_values[i + 1]:
									if not vala:
											__UpperCAmelCase       :	Union[str, Any]						=      self._card_values[i]
											kind += 1
									elif vala == self._card_values[i]:
											kind += 2
									elif not vala:
											__UpperCAmelCase       :	Union[str, Any]						=      self._card_values[i]
											kind += 1
									elif vala == self._card_values[i]:
											kind += 2
        # For consistency in hand type (look at note in _get_hand_type function)
					__UpperCAmelCase       :	Optional[Any]						=      kind + 2 if kind in [4, 5] else kind
					# first meaning first pair to compare in 'compare_with'
					__UpperCAmelCase       :	Tuple						=      max(a_			,			a_					)
					__UpperCAmelCase       :	List[Any]						=      min(a_			,			a_					)
					# If it's full house (three count pair + two count pair), make sure
					# first pair is three count and if not then switch them both.
					if kind == 6 and self._card_values.count(a_					) != 3:
							__UpperCAmelCase				,   __UpperCAmelCase       :	List[Any]						=      second, first
					__UpperCAmelCase       :	List[str]						=      first
					__UpperCAmelCase       :	List[str]						=      second
					return kind




			def 					snake_case__	(  self				:					List[Any]					):
					'''simple docstring'''





					__UpperCAmelCase       :	dict						=      {"T": "10", "J": "11", "Q": "12", "K": "13", "A": "14"}
					__UpperCAmelCase       :	Optional[int]						=      self._hand.translate(str.maketrans(a_					)					).split()
					__UpperCAmelCase       :	Tuple						=      [int(card[:-1]					) for card in new_hand]
					__UpperCAmelCase       :	Tuple						=      {card[-1] for card in new_hand}
					return sorted(a_			,			reverse=a_					), card_suit




			def __repr__(  self				:					Any					):
					'''simple docstring'''





					return F'{self.__class__}("{self._hand}")'




			def __str__(  self				:					int					):
					'''simple docstring'''





					return self._hand




			def __eq__(  self				:					List[str]			,			a_				:					Any					):
					'''simple docstring'''





					if isinstance(a_			,			a_					):
							return self.compare_with(a_					) == "Tie"
					return NotImplemented




			def __lt__(  self				:					List[Any]			,			a_				:					int					):
					'''simple docstring'''





					if isinstance(a_			,			a_					):
							return self.compare_with(a_					) == "Loss"
					return NotImplemented




			def __le__(  self				:					str			,			a_				:					int					):
					'''simple docstring'''





					if isinstance(a_			,			a_					):
							return self < other or self == other
					return NotImplemented




			def __gt__(  self				:					Any			,			a_				:					List[Any]					):
					'''simple docstring'''





					if isinstance(a_			,			a_					):
							return not self < other and self != other
					return NotImplemented




			def __ge__(  self				:					str			,			a_				:					Optional[int]					):
					'''simple docstring'''





					if isinstance(a_			,			a_					):
							return not self < other
					return NotImplemented




			def __hash__(  self				:					int					):
					'''simple docstring'''





					return object.__hash__(self					)

def 			a		( ):







		'''simple docstring'''





		__UpperCAmelCase       :	Dict						=      0
		__UpperCAmelCase       :	Tuple						=      os.path.abspath(os.path.dirname(_UpperCAmelCase		)		)
		__UpperCAmelCase       :	Union[str, Any]						=      os.path.join(_UpperCAmelCase					,  '''poker_hands.txt'''		)
		with open(_UpperCAmelCase		) as file_hand:
				for line in file_hand:
						__UpperCAmelCase       :	str						=      line[:14].strip()
						__UpperCAmelCase       :	List[Any]						=      line[15:].strip()
						__UpperCAmelCase				,   __UpperCAmelCase       :	Tuple						=      PokerHand(_UpperCAmelCase		), PokerHand(_UpperCAmelCase		)
						__UpperCAmelCase       :	Dict						=      player.compare_with(_UpperCAmelCase		)
						if output == "Win":
								answer += 1
		return answer


if __name__ == "__main__":
				solution()










import json
import os
import shutil
import tempfile
import unittest

from transformers import is_speech_available, is_torch_available
from transformers.models.speechta import SpeechTaTokenizer
from transformers.testing_utils import get_tests_dir, require_torch
from transformers.utils import FEATURE_EXTRACTOR_NAME


if is_speech_available() and is_torch_available():
				from transformers import SpeechTaFeatureExtractor, SpeechTaProcessor

				from .test_feature_extraction_speechta import floats_list


__A       =get_tests_dir("fixtures/test_sentencepiece_bpe_char.model")

@require_torch
class 						UpperCAmelCase__     (     unittest.TestCase  ):




			'''simple docstring'''






			def 					snake_case__	(  self				:					List[str]					):
					'''simple docstring'''





					__UpperCAmelCase       :	str						=      tempfile.mkdtemp()

					__UpperCAmelCase       :	Optional[int]						=      SpeechTaTokenizer(a_					)
					tokenizer.save_pretrained(self.tmpdirname					)

					__UpperCAmelCase       :	Union[str, Any]						=      {
					    '''feature_size''': 1,
					    '''padding_value''': 0.0,
					    '''sampling_rate''': 1_60_00,
					    '''do_normalize''': False,
					    '''num_mel_bins''': 80,
					    '''hop_length''': 16,
					    '''win_length''': 64,
					    '''win_function''': '''hann_window''',
					    '''fmin''': 80,
					    '''fmax''': 76_00,
					    '''mel_floor''': 1e-10,
					    '''reduction_factor''': 2,
					    '''return_attention_mask''': True,
					}

					__UpperCAmelCase       :	Tuple						=      os.path.join(self.tmpdirname			,			a_					)
					with open(self.feature_extraction_file			,			'''w'''			,			encoding='''utf-8'''					) as fp:
							fp.write(json.dumps(a_					) + '''\n'''					)




			def 					snake_case__	(  self				:					Any			,			**a_				:					Tuple					):
					'''simple docstring'''





					return SpeechTaTokenizer.from_pretrained(self.tmpdirname			,			**a_					)




			def 					snake_case__	(  self				:					Dict			,			**a_				:					str					):
					'''simple docstring'''





					return SpeechTaFeatureExtractor.from_pretrained(self.tmpdirname			,			**a_					)




			def 					snake_case__	(  self				:					List[str]					):
					'''simple docstring'''





					shutil.rmtree(self.tmpdirname					)




			def 					snake_case__	(  self				:					Dict					):
					'''simple docstring'''





					__UpperCAmelCase       :	int						=      self.get_tokenizer()
					__UpperCAmelCase       :	str						=      self.get_feature_extractor()

					__UpperCAmelCase       :	List[Any]						=      SpeechTaProcessor(tokenizer=a_			,			feature_extractor=a_					)

					processor.save_pretrained(self.tmpdirname					)
					__UpperCAmelCase       :	List[str]						=      SpeechTaProcessor.from_pretrained(self.tmpdirname					)

					self.assertEqual(processor.tokenizer.get_vocab()			,			tokenizer.get_vocab()					)
					self.assertIsInstance(processor.tokenizer			,			a_					)

					self.assertEqual(processor.feature_extractor.to_json_string()			,			feature_extractor.to_json_string()					)
					self.assertIsInstance(processor.feature_extractor			,			a_					)




			def 					snake_case__	(  self				:					int					):
					'''simple docstring'''





					__UpperCAmelCase       :	Optional[int]						=      SpeechTaProcessor(tokenizer=self.get_tokenizer()			,			feature_extractor=self.get_feature_extractor()					)
					processor.save_pretrained(self.tmpdirname					)

					__UpperCAmelCase       :	Optional[Any]						=      self.get_tokenizer(bos_token='''(BOS)'''			,			eos_token='''(EOS)'''					)
					__UpperCAmelCase       :	List[Any]						=      self.get_feature_extractor(do_normalize=a_			,			padding_value=1.0					)

					__UpperCAmelCase       :	List[str]						=      SpeechTaProcessor.from_pretrained(
					    self.tmpdirname			,			bos_token='''(BOS)'''			,			eos_token='''(EOS)'''			,			do_normalize=a_			,			padding_value=1.0					)

					self.assertEqual(processor.tokenizer.get_vocab()			,			tokenizer_add_kwargs.get_vocab()					)
					self.assertIsInstance(processor.tokenizer			,			a_					)

					self.assertEqual(processor.feature_extractor.to_json_string()			,			feature_extractor_add_kwargs.to_json_string()					)
					self.assertIsInstance(processor.feature_extractor			,			a_					)




			def 					snake_case__	(  self				:					Union[str, Any]					):
					'''simple docstring'''





					__UpperCAmelCase       :	Optional[Any]						=      self.get_feature_extractor()
					__UpperCAmelCase       :	Union[str, Any]						=      self.get_tokenizer()

					__UpperCAmelCase       :	List[Any]						=      SpeechTaProcessor(tokenizer=a_			,			feature_extractor=a_					)

					__UpperCAmelCase       :	List[Any]						=      floats_list((3, 10_00)					)

					__UpperCAmelCase       :	Tuple						=      feature_extractor(audio=a_			,			return_tensors='''np'''					)
					__UpperCAmelCase       :	List[str]						=      processor(audio=a_			,			return_tensors='''np'''					)

					for key in input_feat_extract.keys():
							self.assertAlmostEqual(input_feat_extract[key].sum()			,			input_processor[key].sum()			,			delta=1e-2					)




			def 					snake_case__	(  self				:					Optional[Any]					):
					'''simple docstring'''





					__UpperCAmelCase       :	List[Any]						=      self.get_feature_extractor()
					__UpperCAmelCase       :	Dict						=      self.get_tokenizer()

					__UpperCAmelCase       :	Optional[Any]						=      SpeechTaProcessor(tokenizer=a_			,			feature_extractor=a_					)

					__UpperCAmelCase       :	Union[str, Any]						=      floats_list((3, 10_00)					)

					__UpperCAmelCase       :	Dict						=      feature_extractor(audio_target=a_			,			return_tensors='''np'''					)
					__UpperCAmelCase       :	str						=      processor(audio_target=a_			,			return_tensors='''np'''					)

					for key in input_feat_extract.keys():
							self.assertAlmostEqual(input_feat_extract[key].sum()			,			input_processor[key].sum()			,			delta=1e-2					)




			def 					snake_case__	(  self				:					Union[str, Any]					):
					'''simple docstring'''





					__UpperCAmelCase       :	Union[str, Any]						=      self.get_feature_extractor()
					__UpperCAmelCase       :	Optional[int]						=      self.get_tokenizer()

					__UpperCAmelCase       :	Optional[Any]						=      SpeechTaProcessor(tokenizer=a_			,			feature_extractor=a_					)

					__UpperCAmelCase       :	List[str]						=      '''This is a test string'''

					__UpperCAmelCase       :	List[Any]						=      processor(text=a_					)
					__UpperCAmelCase       :	Optional[int]						=      tokenizer(a_					)

					for key in encoded_tok.keys():
							self.assertListEqual(encoded_tok[key]			,			encoded_processor[key]					)




			def 					snake_case__	(  self				:					List[str]					):
					'''simple docstring'''





					__UpperCAmelCase       :	Optional[Any]						=      self.get_feature_extractor()
					__UpperCAmelCase       :	Optional[Any]						=      self.get_tokenizer()

					__UpperCAmelCase       :	List[Any]						=      SpeechTaProcessor(tokenizer=a_			,			feature_extractor=a_					)

					__UpperCAmelCase       :	List[str]						=      '''This is a test string'''

					__UpperCAmelCase       :	Optional[Any]						=      processor(text_target=a_					)
					__UpperCAmelCase       :	Optional[int]						=      tokenizer(a_					)

					for key in encoded_tok.keys():
							self.assertListEqual(encoded_tok[key]			,			encoded_processor[key]					)




			def 					snake_case__	(  self				:					List[str]					):
					'''simple docstring'''





					__UpperCAmelCase       :	int						=      self.get_feature_extractor()
					__UpperCAmelCase       :	Union[str, Any]						=      self.get_tokenizer()

					__UpperCAmelCase       :	int						=      SpeechTaProcessor(tokenizer=a_			,			feature_extractor=a_					)

					__UpperCAmelCase       :	Optional[Any]						=      [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

					__UpperCAmelCase       :	Optional[Any]						=      processor.batch_decode(a_					)
					__UpperCAmelCase       :	Any						=      tokenizer.batch_decode(a_					)

					self.assertListEqual(a_			,			a_					)




			def 					snake_case__	(  self				:					str					):
					'''simple docstring'''





					__UpperCAmelCase       :	str						=      self.get_feature_extractor()
					__UpperCAmelCase       :	str						=      self.get_tokenizer()

					__UpperCAmelCase       :	Optional[Any]						=      SpeechTaProcessor(tokenizer=a_			,			feature_extractor=a_					)

					self.assertListEqual(
					    processor.model_input_names			,			feature_extractor.model_input_names			,			msg='''`processor` and `feature_extractor` model input names do not match'''			,			)





