
'''simple docstring'''







def 					UpperCAmelCase_		(__a      :    int ):






   """simple docstring"""

   if bit_count < 0:
      raise ValueError('The given input must be positive' )

   # get the generated string sequence
   _a				:	str			=   gray_code_sequence_string(__a )
   #
   # convert them to integers
   for i in range(len(__a ) ):
      _a				:	Union[str, Any]			=   int(sequence[i] ,	2 )

   return sequence





def 					UpperCAmelCase_		(__a      :    int ):






   """simple docstring"""

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

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

   _a				:	str			=   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
   _a				:	Union[str, Any]			=   gray_code_sequence_string(bit_count - 1 )

   _a				:	List[Any]			=   []

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

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

   return sequence


if __name__ == "__main__":
  import doctest

  doctest.testmod()





'''simple docstring'''







class UpperCAmelCase__	:





  """simple docstring"""

  def __init__(		self      :     Dict       ):


     '''simple docstring'''






     _a				:	Dict			=   {}


  def   __lowercase		(		self      :     Union[str, Any]       ):


     '''simple docstring'''






     print(self.vertex       )
     for i in self.vertex:
        print(_a							,' -> '							,' -> '.join([str(_a       ) for j in self.vertex[i]]       )       )


  def   __lowercase		(		self      :     Dict							,_a      :     int							,_a      :     int       ):


     '''simple docstring'''






     if from_vertex in self.vertex:
        self.vertex[from_vertex].append(_a       )
     else:
        # else make a new vertex
        _a				:	int			=   [to_vertex]


  def   __lowercase		(		self      :     Optional[int]       ):


     '''simple docstring'''






     _a				:	Tuple			=   [False] * len(self.vertex       )

     # call the recursive helper function
     for i in range(len(self.vertex       )       ):
        if not visited[i]:
           self.dfs_recursive(_a							,_a       )


  def   __lowercase		(		self      :     Union[str, Any]							,_a      :     int							,_a      :     list       ):


     '''simple docstring'''






     _a				:	List[Any]			=   True

     print(_a							,end=' '       )

     # Recur for all the vertices that are adjacent to this node
     for i in self.vertex:
        if not visited[i]:
           self.dfs_recursive(_a							,_a       )


if __name__ == "__main__":
  __lowerCAmelCase         =    Graph()
  g.add_edge(0, 1)
  g.add_edge(0, 2)
  g.add_edge(1, 2)
  g.add_edge(2, 0)
  g.add_edge(2, 3)
  g.add_edge(3, 3)

  g.print_graph()
  print("""DFS:""")
  g.dfs()

  # OUTPUT:
  # 0  ->  1 -> 2
  # 1  ->  2
  # 2  ->  0 -> 3
  # 3  ->  3
  # DFS:
  #  0 1 2 3



