

"""simple docstring"""


from unittest import TestCase

from datasets import Sequence, Value
from datasets.arrow_dataset import Dataset

class      __a							(UpperCamelCase_):






     '''simple docstring'''

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


           """simple docstring"""


           return [
               {"col_1": 3, "col_2": "a"},
               {"col_1": 2, "col_2": "b"},
               {"col_1": 1, "col_2": "c"},
               {"col_1": 0, "col_2": "d"},
           ]

     def 					_a			(						self  )  ->      Any:


           """simple docstring"""


           SCREAMING_SNAKE_CASE__   :      Optional[int]      		=	{"""col_1""": [3, 2, 1, 0], """col_2""": ["""a""", """b""", """c""", """d"""]}
           return Dataset.from_dict(_a  )

     def 					_a			(						self  )  ->      Optional[Any]:


           """simple docstring"""


           SCREAMING_SNAKE_CASE__   :      str      		=	self._create_example_records()
           SCREAMING_SNAKE_CASE__   :      Tuple      		=	Dataset.from_list(_a  )
           self.assertListEqual(dset.column_names	,    ["""col_1""", """col_2"""]  )
           for i, r in enumerate(_a  ):
                 self.assertDictEqual(_a	,    example_records[i]  )

     def 					_a			(						self  )  ->      Any:


           """simple docstring"""


           SCREAMING_SNAKE_CASE__   :      List[str]      		=	self._create_example_records()
           SCREAMING_SNAKE_CASE__   :      Tuple      		=	Dataset.from_list(_a  )
           SCREAMING_SNAKE_CASE__   :      Any      		=	Dataset.from_dict({k: [r[k] for r in example_records] for k in example_records[0]}  )
           self.assertEqual(dset.info	,    dset_from_dict.info  )

     def 					_a			(						self  )  ->      Dict:  # checks what happens with missing columns


           """simple docstring"""


           SCREAMING_SNAKE_CASE__   :      List[str]      		=	[{"""col_1""": 1}, {"""col_2""": """x"""}]
           SCREAMING_SNAKE_CASE__   :      Optional[int]      		=	Dataset.from_list(_a  )
           self.assertDictEqual(dset[0]	,    {"""col_1""": 1}  )
           self.assertDictEqual(dset[1]	,    {"""col_1""": None}  )  # NB: first record is used for columns

     def 					_a			(						self  )  ->      str:  # checks if the type can be inferred from the second record


           """simple docstring"""


           SCREAMING_SNAKE_CASE__   :      Union[str, Any]      		=	[{"""col_1""": []}, {"""col_1""": [1, 2]}]
           SCREAMING_SNAKE_CASE__   :      List[str]      		=	Dataset.from_list(_a  )
           self.assertEqual(dset.info.features["""col_1"""]	,    Sequence(Value("""int64"""  )  )  )





     def 					_a			(						self  )  ->      List[Any]:


           """simple docstring"""


           SCREAMING_SNAKE_CASE__   :      Union[str, Any]      		=	Dataset.from_list([]  )
           self.assertEqual(len(_a  )	,    0  )
           self.assertListEqual(dset.column_names	,    []  )







"""simple docstring"""


import os

a					:List[str]    = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1_000}




def  _lowercase					(    __lowerCAmelCase							)       ->				int:
      SCREAMING_SNAKE_CASE__   :      Any      		=	0

      SCREAMING_SNAKE_CASE__   :      Dict      		=	0
      while index < len(__lowerCAmelCase							) - 1:
            SCREAMING_SNAKE_CASE__   :      List[Any]      		=	SYMBOLS[numerals[index]]
            SCREAMING_SNAKE_CASE__   :      Dict      		=	SYMBOLS[numerals[index + 1]]
            if current_value < next_value:
                  total_value -= current_value
            else:
                  total_value += current_value
            index += 1
      total_value += SYMBOLS[numerals[index]]

      return total_value




def  _lowercase					(    __lowerCAmelCase							)       ->				str:
      SCREAMING_SNAKE_CASE__   :      Optional[int]      		=	""""""

      SCREAMING_SNAKE_CASE__   :      int      		=	num // 1000
      numerals += m_count * "M"
      num %= 1000

      SCREAMING_SNAKE_CASE__   :      List[str]      		=	num // 100
      if c_count == 9:
            numerals += "CM"
            c_count -= 9
      elif c_count == 4:
            numerals += "CD"
            c_count -= 4
      if c_count >= 5:
            numerals += "D"
            c_count -= 5
      numerals += c_count * "C"
      num %= 100

      SCREAMING_SNAKE_CASE__   :      List[Any]      		=	num // 10
      if x_count == 9:
            numerals += "XC"
            x_count -= 9
      elif x_count == 4:
            numerals += "XL"
            x_count -= 4
      if x_count >= 5:
            numerals += "L"
            x_count -= 5
      numerals += x_count * "X"
      num %= 10

      if num == 9:
            numerals += "IX"
            num -= 9
      elif num == 4:
            numerals += "IV"
            num -= 4
      if num >= 5:
            numerals += "V"
            num -= 5
      numerals += num * "I"

      return numerals




def  _lowercase					(    __lowerCAmelCase = "/p089_roman.txt"							)       ->				int:
      SCREAMING_SNAKE_CASE__   :      int      		=	0

      with open(os.path.dirname(__lowerCAmelCase							) + roman_numerals_filename							) as filea:
            SCREAMING_SNAKE_CASE__   :      str      		=	filea.readlines()

      for line in lines:
            SCREAMING_SNAKE_CASE__   :      Union[str, Any]      		=	line.strip()
            SCREAMING_SNAKE_CASE__   :      Dict      		=	parse_roman_numerals(__lowerCAmelCase							)
            SCREAMING_SNAKE_CASE__   :      str      		=	generate_roman_numerals(__lowerCAmelCase							)
            savings += len(__lowerCAmelCase							) - len(__lowerCAmelCase							)

      return savings


if __name__ == "__main__":
  print(f'{solution() = }')




