
"""simple docstring"""







import itertools
from dataclasses import dataclass
from typing import Optional

import pyarrow as pa

import datasets
from datasets.table import table_cast


lowercase_						    =					datasets.utils.logging.get_logger(__name__)



@dataclass
class 		UpperCAmelCase_	(datasets.BuilderConfig						):
 """simple docstring"""




 UpperCamelCase_						:     Optional[datasets.Features]				   =    None



class 		UpperCAmelCase_	(datasets.ArrowBasedBuilder						):
 """simple docstring"""




 UpperCamelCase_						:     Any				   =    ArrowConfig




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



      """simple docstring"""

      return datasets.DatasetInfo(features=self.config.features )




 def   a      ( self       : List[str]     ,   a_       : Tuple )->					Tuple:



      """simple docstring"""

      if not self.config.data_files:
           raise ValueError(f'''At least one data file must be specified, but got data_files={self.config.data_files}''' )
      UpperCAmelCase_						:    Any    					=  dl_manager.download_and_extract(self.config.data_files )
      if isinstance(a_     ,   (str, list, tuple) ):
           UpperCAmelCase_						:    Tuple    					=  data_files
           if isinstance(a_     ,   a_ ):
                UpperCAmelCase_						:    List[str]    					=  [files]
           # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
           UpperCAmelCase_						:    Optional[Any]    					=  [dl_manager.iter_files(a_ ) for file in files]
           return [datasets.SplitGenerator(name=datasets.Split.TRAIN     ,   gen_kwargs={"""files""": files} )]
      UpperCAmelCase_						:    Optional[int]    					=  []
      for split_name, files in data_files.items():
           if isinstance(a_     ,   a_ ):
                UpperCAmelCase_						:    Optional[int]    					=  [files]
           # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
           UpperCAmelCase_						:    Any    					=  [dl_manager.iter_files(a_ ) for file in files]
           # Infer features is they are stoed in the arrow schema
           if self.info.features is None:
                for file in itertools.chain.from_iterable(a_ ):
                     with open(a_     ,   """rb""" ) as f:
                          UpperCAmelCase_						:    List[str]    					=  datasets.Features.from_arrow_schema(pa.ipc.open_stream(a_ ).schema )
                     break
           splits.append(datasets.SplitGenerator(name=a_     ,   gen_kwargs={"""files""": files} ) )
      return splits




 def   a      ( self       : Union[str, Any]     ,   a_       : pa.Table )->					pa.Table:



      """simple docstring"""

      if self.info.features is not None:
           # more expensive cast to support nested features with keys in a different order
           # allows str <-> int/float or str to Audio for example
           UpperCAmelCase_						:    List[Any]    					=  table_cast(a_     ,   self.info.features.arrow_schema )
      return pa_table






 def   a      ( self       : List[str]     ,   a_       : Tuple )->					Dict:



      """simple docstring"""

      for file_idx, file in enumerate(itertools.chain.from_iterable(a_ ) ):
           with open(a_     ,   """rb""" ) as f:
                try:
                     for batch_idx, record_batch in enumerate(pa.ipc.open_stream(a_ ) ):
                          UpperCAmelCase_						:    Tuple    					=  pa.Table.from_batches([record_batch] )
                          # Uncomment for debugging (will print the Arrow table size and elements)
                          # logger.warning(f"pa_table: {pa_table} num rows: {pa_table.num_rows}")
                          # logger.warning('\n'.join(str(pa_table.slice(i, 1).to_pydict()) for i in range(pa_table.num_rows)))
                          yield f'''{file_idx}_{batch_idx}''', self._cast_table(a_ )
                except ValueError as e:
                     logger.error(f'''Failed to read file \'{file}\' with error {type(a_ )}: {e}''' )
                     raise



"""simple docstring"""







def 			A_			(					lowercase = 99_8001      )     ->							int:


     """simple docstring"""







     for number in range(n - 1						, 9999						, -1      ):
          UpperCAmelCase_						:    Union[str, Any]    					=  str(lowercase      )

          # checks whether 'str_number' is a palindrome.
          if str_number == str_number[::-1]:
               UpperCAmelCase_						:    List[str]    					=  999

               # if 'number' is a product of two 3-digit numbers
               # then number is the answer otherwise fetch next number.
               while divisor != 99:
                    if (number % divisor == 0) and (len(str(number // divisor      )      ) == 3.0):
                         return number
                    divisor -= 1
     raise ValueError("""That number is larger than our acceptable range."""      )


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

