'''simple docstring'''

from __future__ import annotations

# This is the precision for this function which can be altered.
# It is recommended for users to keep this number greater than or equal to 10.
_A			:      Union[str, Any]					      =				10







def      UpperCamelCase_						(					snake_case_       :       int						,		snake_case_       :       int						,		snake_case_       :       list[int]						,		snake_case_       :       int      )					->     int:






 '''simple docstring'''

 for i in range(snake_case_						,		snake_case_      ):
  if array[i] == target:
   return i
 return -1







def      UpperCamelCase_						(					snake_case_       :       list[int]						,		snake_case_       :       int      )					->     int:






 '''simple docstring'''

 __lowerCAmelCase											=						0
 __lowerCAmelCase											=						len(snake_case_      )
 while left <= right:
  if right - left < precision:
   return lin_search(snake_case_						,		snake_case_						,		snake_case_						,		snake_case_      )

  __lowerCAmelCase											=						(left + right) // 3 + 1
  __lowerCAmelCase											=						2 * (left + right) // 3 + 1

  if array[one_third] == target:
   return one_third
  elif array[two_third] == target:
   return two_third

  elif target < array[one_third]:
   __lowerCAmelCase											=						one_third - 1
  elif array[two_third] < target:
   __lowerCAmelCase											=						two_third + 1

  else:
   __lowerCAmelCase											=						one_third + 1
   __lowerCAmelCase											=						two_third - 1
 else:
  return -1







def      UpperCamelCase_						(					snake_case_       :       int						,		snake_case_       :       int						,		snake_case_       :       list[int]						,		snake_case_       :       int      )					->     int:






 '''simple docstring'''

 if left < right:
  if right - left < precision:
   return lin_search(snake_case_						,		snake_case_						,		snake_case_						,		snake_case_      )
  __lowerCAmelCase											=						(left + right) // 3 + 1
  __lowerCAmelCase											=						2 * (left + right) // 3 + 1

  if array[one_third] == target:
   return one_third
  elif array[two_third] == target:
   return two_third

  elif target < array[one_third]:
   return rec_ternary_search(snake_case_						,		one_third - 1						,		snake_case_						,		snake_case_      )
  elif array[two_third] < target:
   return rec_ternary_search(two_third + 1						,		snake_case_						,		snake_case_						,		snake_case_      )
  else:
   return rec_ternary_search(one_third + 1						,		two_third - 1						,		snake_case_						,		snake_case_      )
 else:
  return -1


if __name__ == "__main__":
 import doctest

 doctest.testmod()

 _A			:      Optional[int]					      =				input('''Enter numbers separated by comma:\n''').strip()
 _A			:      List[Any]					      =				[int(item.strip()) for item in user_input.split(''',''')]
 assert collection == sorted(collection), f"List must be ordered.\n{collection}."
 _A			:      Union[str, Any]					      =				int(input('''Enter the number to be found in the list:\n''').strip())
 _A			:      Tuple					      =				ite_ternary_search(collection, target)
 _A			:      Dict					      =				rec_ternary_search(0, len(collection) - 1, collection, target)
 if resulta != -1:
  print(f'Iterative search: {target} found at positions: {resulta}')
  print(f'Recursive search: {target} found at positions: {resulta}')
 else:
  print('''Not found''')







'''simple docstring'''

from unittest import TestCase

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







class 				_lowercase     (				UpperCAmelCase__			):


 '''simple docstring'''






 def a					(      self   :	int							)  ->    Optional[Any]:
  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   :	List[Any]							)  ->    Any:
  __lowerCAmelCase											=						{"""col_1""": [3, 2, 1, 0], """col_2""": ["""a""", """b""", """c""", """d"""]}
  return Dataset.from_dict(SCREAMING_SNAKE_CASE__							)
 def a					(      self   :	List[Any]							)  ->    Tuple:
  __lowerCAmelCase											=						self._create_example_records()
  __lowerCAmelCase											=						Dataset.from_list(SCREAMING_SNAKE_CASE__							)
  self.assertListEqual(dset.column_names      ,       ["""col_1""", """col_2"""]							)
  for i, r in enumerate(SCREAMING_SNAKE_CASE__							):
   self.assertDictEqual(SCREAMING_SNAKE_CASE__      ,       example_records[i]							)
 def a					(      self   :	Tuple							)  ->    List[str]:
  __lowerCAmelCase											=						self._create_example_records()
  __lowerCAmelCase											=						Dataset.from_list(SCREAMING_SNAKE_CASE__							)
  __lowerCAmelCase											=						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   :	List[str]							)  ->    List[str]:  # checks what happens with missing columns
  __lowerCAmelCase											=						[{"""col_1""": 1}, {"""col_2""": """x"""}]
  __lowerCAmelCase											=						Dataset.from_list(SCREAMING_SNAKE_CASE__							)
  self.assertDictEqual(dset[0]      ,       {"""col_1""": 1}							)
  self.assertDictEqual(dset[1]      ,       {"""col_1""": None}							)  # NB: first record is used for columns
 def a					(      self   :	Dict							)  ->    Optional[int]:  # checks if the type can be inferred from the second record
  __lowerCAmelCase											=						[{"""col_1""": []}, {"""col_1""": [1, 2]}]
  __lowerCAmelCase											=						Dataset.from_list(SCREAMING_SNAKE_CASE__							)
  self.assertEqual(dset.info.features["""col_1"""]      ,       Sequence(Value("""int64"""							)							)							)





 def a					(      self   :	Optional[Any]							)  ->    Tuple:
  __lowerCAmelCase											=						Dataset.from_list([]							)
  self.assertEqual(len(SCREAMING_SNAKE_CASE__							)      ,       0							)
  self.assertListEqual(dset.column_names      ,       []							)






