




'''simple docstring'''

def __UpperCAmelCase	(   _UpperCAmelCase		:   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
			__snake_case			=		gray_code_sequence_string(_UpperCAmelCase						)
			#
			# convert them to integers
			for i in range(len(_UpperCAmelCase						)						):
						__snake_case			=		int(sequence[i]		,				2						)

			return sequence


def __UpperCAmelCase	(   _UpperCAmelCase		:   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"]

			__snake_case			=		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
			__snake_case			=		gray_code_sequence_string(bit_count - 1						)

			__snake_case			=		[]

			# append 0 to first half of the smaller sequence generated
			for i in range(seq_len // 2						):
						__snake_case			=		"0" + smaller_sequence[i]
						sequence.append(_UpperCAmelCase						)

			# append 1 to second half ... start from the end of the list
			for i in reversed(range(seq_len // 2						)						):
						__snake_case			=		"1" + smaller_sequence[i]
						sequence.append(_UpperCAmelCase						)

			return sequence


if __name__ == "__main__":
						import doctest

						doctest.testmod()









class   SCREAMING_SNAKE_CASE_			:




       '''simple docstring'''



       def __init__(						self				:				Tuple		,				__a				:				int							)					->Optional[int]:
          lowerCamelCase_						:   Optional[Any]		= n
          lowerCamelCase_						:   Dict		= [None] * self.n
          lowerCamelCase_						:   int		= 0  # index of the first element
          lowerCamelCase_						:   str		= 0
          lowerCamelCase_						:   Optional[Any]		= 0



       def __len__(						self				:				List[str]							)					->int:
          return self.size



       def 				_lowerCAmelCase							(						self				:				str							)					->bool:
          return self.size == 0



       def 				_lowerCAmelCase							(						self				:				str							)					->Any:
          return False if self.is_empty() else self.array[self.front]



       def 				_lowerCAmelCase							(						self				:				Union[str, Any]		,				__a				:				int							)					->List[Any]:
          if self.size >= self.n:
             raise Exception("""QUEUE IS FULL"""							)

          lowerCamelCase_						:   Tuple		= data
          lowerCamelCase_						:   Tuple		= (self.rear + 1) % self.n
          self.size += 1
          return self




       def 				_lowerCAmelCase							(						self				:				Tuple							)					->int:
          if self.size == 0:
             raise Exception("""UNDERFLOW"""							)

          lowerCamelCase_						:   str		= self.array[self.front]
          lowerCamelCase_						:   str		= None
          lowerCamelCase_						:   Optional[Any]		= (self.front + 1) % self.n
          self.size -= 1
          return temp





