



'''simple docstring'''






def  snake_case_     (					_lowerCAmelCase  :						int  )      ->   list:

							# bit count represents no. of bits in the gray code
							if bit_count < 0:
														raise ValueError('''The given input must be positive'''  )

							# get the generated string sequence
							UpperCAmelCase :       List[str] 							=		gray_code_sequence_string(_lowerCAmelCase  )
							#
							# convert them to integers
							for i in range(len(_lowerCAmelCase  )  ):
														UpperCAmelCase :       Optional[int] 							=		int(sequence[i]   ,      2  )

							return sequence


def  snake_case_     (					_lowerCAmelCase  :						int  )      ->   list:

							# The approach is a recursive one
							# Base case achieved when either n = 0 or n=1
							if bit_count == 0:
														return ["0"]

							if bit_count == 1:
														return ["0", "1"]

							UpperCAmelCase :       Optional[int] 							=		1 << bit_count  # defines the length of the sequence
							# 1<< n is equivalent to 2^n

							# recursive answer will generate answer for n-1 bits
							UpperCAmelCase :       Optional[Any] 							=		gray_code_sequence_string(bit_count - 1  )

							UpperCAmelCase :       Tuple 							=		[]

							# append 0 to first half of the smaller sequence generated
							for i in range(seq_len // 2  ):
														UpperCAmelCase :       Tuple 							=		'''0''' + smaller_sequence[i]
														sequence.append(_lowerCAmelCase  )

							# append 1 to second half ... start from the end of the list
							for i in reversed(range(seq_len // 2  )  ):
														UpperCAmelCase :       Optional[Any] 							=		'''1''' + smaller_sequence[i]
														sequence.append(_lowerCAmelCase  )

							return sequence


if __name__ == "__main__":
						import doctest

						doctest.testmod()










'''simple docstring'''






from math import isclose, sqrt


def  snake_case_     (					_lowerCAmelCase  :						float   ,      _lowerCAmelCase  :						float   ,      _lowerCAmelCase  :						float  )      ->   tuple[float, float, float]:
							UpperCAmelCase :       Optional[int] 							=		point_y / 4 / point_x
							UpperCAmelCase :       str 							=		2 * normal_gradient / (1 + normal_gradient * normal_gradient)
							UpperCAmelCase :       Any 							=		(1 - normal_gradient * normal_gradient) / (
							    1 + normal_gradient * normal_gradient
							)
							UpperCAmelCase :       Union[str, Any] 							=		(sa - ca * incoming_gradient) / (ca + sa * incoming_gradient)

							# to find the next point, solve the simultaeneous equations:
							# y^2 + 4x^2 = 100
							# y - b = m * (x - a)
							# ==> A x^2 + B x + C = 0
							UpperCAmelCase :       Union[str, Any] 							=		outgoing_gradient**2 + 4
							UpperCAmelCase :       Dict 							=		2 * outgoing_gradient * (point_y - outgoing_gradient * point_x)
							UpperCAmelCase :       List[Any] 							=		(point_y - outgoing_gradient * point_x) ** 2 - 100

							UpperCAmelCase :       List[str] 							=		(
							    -linear_term - sqrt(linear_term**2 - 4 * quadratic_term * constant_term  )
							) / (2 * quadratic_term)
							UpperCAmelCase :       Optional[int] 							=		(
							    -linear_term + sqrt(linear_term**2 - 4 * quadratic_term * constant_term  )
							) / (2 * quadratic_term)

							# two solutions, one of which is our input point
							UpperCAmelCase :       Optional[Any] 							=		x_minus if isclose(_lowerCAmelCase   ,      _lowerCAmelCase  ) else x_plus
							UpperCAmelCase :       Union[str, Any] 							=		point_y + outgoing_gradient * (next_x - point_x)

							return next_x, next_y, outgoing_gradient


def  snake_case_     (					_lowerCAmelCase  :						float = 1.4   ,      _lowerCAmelCase  :						float = -9.6  )      ->   int:
							UpperCAmelCase :       int 							=		0
							UpperCAmelCase :       float 							=		first_x_coord
							UpperCAmelCase :       float 							=		first_y_coord
							UpperCAmelCase :       float 							=		(1_0.1 - point_y) / (0.0 - point_x)

							while not (-0.0_1 <= point_x <= 0.0_1 and point_y > 0):
														UpperCAmelCase							,		UpperCAmelCase							,		UpperCAmelCase :       str 							=		next_point(_lowerCAmelCase   ,      _lowerCAmelCase   ,      _lowerCAmelCase  )
														num_reflections += 1

							return num_reflections


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





