

'''simple docstring'''

from unittest import TestCase

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


class 	lowerCAmelCase  (   A ):







       def       snake_case (				self      :			List[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       snake_case (				self      :			Optional[Any]   ):







            """simple docstring"""







            __lowercase      		={'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
            return Dataset.from_dict(__lowercase   )







       def       snake_case (				self      :			str   ):







            """simple docstring"""







            __lowercase      		=self._create_example_records()
            __lowercase      		=Dataset.from_list(__lowercase   )
            self.assertListEqual(dset.column_names    ,   ['col_1', 'col_2']   )
            for i, r in enumerate(__lowercase   ):
                 self.assertDictEqual(__lowercase    ,   example_records[i]   )







       def       snake_case (				self      :			List[Any]   ):







            """simple docstring"""







            __lowercase      		=self._create_example_records()
            __lowercase      		=Dataset.from_list(__lowercase   )
            __lowercase      		=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       snake_case (				self      :			Optional[int]   ):  # checks what happens with missing columns







            """simple docstring"""







            __lowercase      		=[{'col_1': 1}, {'col_2': 'x'}]
            __lowercase      		=Dataset.from_list(__lowercase   )
            self.assertDictEqual(dset[0]    ,   {'col_1': 1}   )
            self.assertDictEqual(dset[1]    ,   {'col_1': None}   )  # NB: first record is used for columns







       def       snake_case (				self      :			int   ):  # checks if the type can be inferred from the second record







            """simple docstring"""







            __lowercase      		=[{'col_1': []}, {'col_1': [1, 2]}]
            __lowercase      		=Dataset.from_list(__lowercase   )
            self.assertEqual(dset.info.features['col_1']    ,   Sequence(Value('int64'   )   )   )







       def       snake_case (				self      :			List[str]   ):







            """simple docstring"""







            __lowercase      		=Dataset.from_list([]   )
            self.assertEqual(len(__lowercase   )    ,   0   )
            self.assertListEqual(dset.column_names    ,   []   )





'''simple docstring'''

def 					__UpperCamelCase				(						lowercase__    :	int			):






     '''simple docstring'''





     if upper_limit < 0:
          raise ValueError('Limit for the Catalan sequence must be ≥ 0'			)

     __lowercase      		=[0] * (upper_limit + 1)

     # Base case: C(0) = C(1) = 1
     __lowercase      		=1
     if upper_limit > 0:
          __lowercase      		=1

     # Recurrence relation: C(i) = sum(C(j).C(i-j-1)), from j = 0 to i
     for i in range(2,       upper_limit + 1			):
          for j in range(lowercase__			):
               catalan_list[i] += catalan_list[j] * catalan_list[i - j - 1]

     return catalan_list


if __name__ == "__main__":
       print('''\n********* Catalan Numbers Using Dynamic Programming ************\n''')
       print('''\n*** Enter -1 at any time to quit ***''')
       print('''\nEnter the upper limit (≥ 0) for the Catalan number sequence: ''', end='''''')
       try:
              while True:
                     UpperCAmelCase					 =	int(input().strip())
                     if N < 0:
                            print('''\n********* Goodbye!! ************''')
                            break
                     else:
                            print(F'''The Catalan numbers from 0 through {N} are:''')
                            print(catalan_numbers(N))
                            print('''Try another upper limit for the sequence: ''', end='''''')
       except (NameError, ValueError):
              print('''\n********* Invalid input, goodbye! ************\n''')

       import doctest

       doctest.testmod()


