"""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.
lowerCAmelCase__						:						str		  =			10



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



def 						a_		(      lowerCamelCase      ,    lowerCamelCase ):
				UpperCAmelCase__    =							0
				UpperCAmelCase__    =							len(lowerCamelCase )
				while left <= right:
								if right - left < precision:
												return lin_search(lowerCamelCase      ,    lowerCamelCase      ,    lowerCamelCase      ,    lowerCamelCase )

								UpperCAmelCase__    =							(left + right) // 3 + 1
								UpperCAmelCase__    =							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]:
												UpperCAmelCase__    =							one_third - 1
								elif array[two_third] < target:
												UpperCAmelCase__    =							two_third + 1

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



def 						a_		(      lowerCamelCase      ,    lowerCamelCase      ,    lowerCamelCase      ,    lowerCamelCase ):
				if left < right:
								if right - left < precision:
												return lin_search(lowerCamelCase      ,    lowerCamelCase      ,    lowerCamelCase      ,    lowerCamelCase )
								UpperCAmelCase__    =							(left + right) // 3 + 1
								UpperCAmelCase__    =							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(lowerCamelCase      ,    one_third - 1      ,    lowerCamelCase      ,    lowerCamelCase )
								elif array[two_third] < target:
												return rec_ternary_search(two_third + 1      ,    lowerCamelCase      ,    lowerCamelCase      ,    lowerCamelCase )
								else:
												return rec_ternary_search(one_third + 1      ,    two_third - 1      ,    lowerCamelCase      ,    lowerCamelCase )
				else:
								return -1


if __name__ == "__main__":
						import doctest

						doctest.testmod()

						lowerCAmelCase__						:						Union[str, Any]		  =			input('Enter numbers separated by comma:\n').strip()
						lowerCAmelCase__						:						int		  =			[int(item.strip()) for item in user_input.split(',')]
						assert collection == sorted(collection), F"List must be ordered.\n{collection}."
						lowerCAmelCase__						:						List[Any]		  =			int(input('Enter the number to be found in the list:\n').strip())
						lowerCAmelCase__						:						str		  =			ite_ternary_search(collection, target)
						lowerCAmelCase__						:						Any		  =			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 __future__ import annotations

from math import ceil, floor, sqrt



def 						a_		(      lowerCamelCase = 2_0_0_0_0_0_0 ):
				UpperCAmelCase__    =							[0]
				UpperCAmelCase__    =							42

				for idx in range(1      ,    ceil(sqrt(target * 2 ) * 1.1 ) ):
								triangle_numbers.append(triangle_numbers[-1] + idx )

				# we want this to be as close as possible to target
				UpperCAmelCase__    =							0
				# the area corresponding to the grid that gives the product closest to target
				UpperCAmelCase__    =							0
				# an estimate of b, using the quadratic formula
				UpperCAmelCase__    =							42
				# the largest integer less than b_estimate
				UpperCAmelCase__    =							42
				# the largest integer less than b_estimate
				UpperCAmelCase__    =							42
				# the triangle number corresponding to b_floor
				UpperCAmelCase__    =							42
				# the triangle number corresponding to b_ceil
				UpperCAmelCase__    =							42

				for idx_a, triangle_a in enumerate(triangle_numbers[1:]      ,    1 ):
								UpperCAmelCase__    =							(-1 + sqrt(1 + 8 * target / triangle_a )) / 2
								UpperCAmelCase__    =							floor(lowerCamelCase )
								UpperCAmelCase__    =							ceil(lowerCamelCase )
								UpperCAmelCase__    =							triangle_numbers[b_floor]
								UpperCAmelCase__    =							triangle_numbers[b_ceil]

								if abs(target - triangle_b_first_guess * triangle_a ) < abs(
								    target - best_product ):
												UpperCAmelCase__    =							triangle_b_first_guess * triangle_a
												UpperCAmelCase__    =							idx_a * b_floor

								if abs(target - triangle_b_second_guess * triangle_a ) < abs(
								    target - best_product ):
												UpperCAmelCase__    =							triangle_b_second_guess * triangle_a
												UpperCAmelCase__    =							idx_a * b_ceil

				return area


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



