



'''simple docstring'''





class 							lowerCAmelCase_		:





    def __init__(    self    :    List[Any],    _snake_case    :    Any     ):



       '''simple docstring'''







       snake_case   :							Tuple						  =data
       snake_case   :							int						  =None
       snake_case   :							List[Any]						  =None






    def __str__(    self    :    List[str]     ):



       '''simple docstring'''







       return f'''{self.data}'''





class 							lowerCAmelCase_		:





    def __init__(    self    :    Optional[int]     ):



       '''simple docstring'''







       snake_case   :							Optional[int]						  =None
       snake_case   :							int						  =None





    def __iter__(    self    :    List[str]     ):



       '''simple docstring'''







       snake_case   :							str						  =self.head
       while node:
          yield node.data
          snake_case   :							Union[str, Any]						  =node.next





    def __str__(    self    :    List[str]     ):



       '''simple docstring'''







       return "->".join([str(_snake_case     ) for item in self]     )





    def __len__(    self    :    Dict     ):



       '''simple docstring'''







       return sum(1 for _ in self     )





    def 					__snake_case       (    self    :    List[Any],    _snake_case    :    str     ):



       '''simple docstring'''







       self.insert_at_nth(0,    _snake_case     )





    def 					__snake_case       (    self    :    Optional[Any],    _snake_case    :    Dict     ):



       '''simple docstring'''







       self.insert_at_nth(len(self     ),    _snake_case     )





    def 					__snake_case       (    self    :    Union[str, Any],    _snake_case    :    int,    _snake_case    :    Dict     ):



       '''simple docstring'''







       snake_case   :							Optional[int]						  =len(self     )

       if not 0 <= index <= length:
          raise IndexError('''list index out of range'''     )
       snake_case   :							int						  =Node(_snake_case     )
       if self.head is None:
          snake_case   :							Optional[Any]						  =new_node
       elif index == 0:
          snake_case   :							int						  =new_node
          snake_case   :							Union[str, Any]						  =self.head
          snake_case   :							Optional[int]						  =new_node
       elif index == length:
          snake_case   :							Dict						  =new_node
          snake_case   :							int						  =self.tail
          snake_case   :							Union[str, Any]						  =new_node
       else:
          snake_case   :							Optional[int]						  =self.head
          for _ in range(0,    _snake_case     ):
             snake_case   :							Union[str, Any]						  =temp.next
          snake_case   :							int						  =new_node
          snake_case   :							Union[str, Any]						  =temp.previous
          snake_case   :							List[Any]						  =temp
          snake_case   :							int						  =new_node





    def 					__snake_case       (    self    :    str     ):



       '''simple docstring'''







       return self.delete_at_nth(0     )





    def 					__snake_case       (    self    :    List[Any]     ):



       '''simple docstring'''







       return self.delete_at_nth(len(self     ) - 1     )





    def 					__snake_case       (    self    :    Union[str, Any],    _snake_case    :    int     ):



       '''simple docstring'''







       snake_case   :							Dict						  =len(self     )

       if not 0 <= index <= length - 1:
          raise IndexError('''list index out of range'''     )
       snake_case   :							List[str]						  =self.head  # default first node
       if length == 1:
          snake_case   :							Union[str, Any]						  =None
       elif index == 0:
          snake_case   :							Tuple						  =self.head.next
          snake_case   :							Optional[int]						  =None
       elif index == length - 1:
          snake_case   :							Union[str, Any]						  =self.tail
          snake_case   :							List[str]						  =self.tail.previous
          snake_case   :							int						  =None
       else:
          snake_case   :							int						  =self.head
          for _ in range(0,    _snake_case     ):
             snake_case   :							Any						  =temp.next
          snake_case   :							List[Any]						  =temp
          snake_case   :							Optional[Any]						  =temp.previous
          snake_case   :							int						  =temp.next
       return delete_node.data





    def 					__snake_case       (    self    :    List[Any],    _snake_case    :    Tuple     ):



       '''simple docstring'''







       snake_case   :							List[Any]						  =self.head

       while current.data != data:  # Find the position to delete
          if current.next:
             snake_case   :							Any						  =current.next
          else:  # We have reached the end an no value matches
             raise ValueError('''No data matching given value'''     )

       if current == self.head:
          self.delete_head()

       elif current == self.tail:
          self.delete_tail()

       else:  # Before: 1 <--> 2(current) <--> 3
          snake_case   :							Optional[int]						  =current.next  # 1 --> 3
          snake_case   :							List[Any]						  =current.previous  # 1 <--> 3
       return data






    def 					__snake_case       (    self    :    Any     ):



       '''simple docstring'''







       return len(self     ) == 0




def 		_a   (  ):
   snake_case   :							Optional[Any]						  =DoublyLinkedList()
   assert linked_list.is_empty() is True
   assert str(lowerCamelCase_							) == ""

   try:
      linked_list.delete_head()
      raise AssertionError  # This should not happen.
   except IndexError:
      assert True  # This should happen.

   try:
      linked_list.delete_tail()
      raise AssertionError  # This should not happen.
   except IndexError:
      assert True  # This should happen.

   for i in range(10							):
      assert len(lowerCamelCase_							) == i
      linked_list.insert_at_nth(lowerCamelCase_					,						i + 1							)
   assert str(lowerCamelCase_							) == "->".join(str(lowerCamelCase_							) for i in range(1					,						11							)							)

   linked_list.insert_at_head(0							)
   linked_list.insert_at_tail(11							)
   assert str(lowerCamelCase_							) == "->".join(str(lowerCamelCase_							) for i in range(0					,						12							)							)

   assert linked_list.delete_head() == 0
   assert linked_list.delete_at_nth(9							) == 10
   assert linked_list.delete_tail() == 11
   assert len(lowerCamelCase_							) == 9
   assert str(lowerCamelCase_							) == "->".join(str(lowerCamelCase_							) for i in range(1					,						10							)							)


if __name__ == "__main__":
      from doctest import testmod

      testmod()










'''simple docstring'''





import doctest

import projectq
from projectq.ops import H, Measure
def 		_a   (  lowerCamelCase_							):
   snake_case   :							str						  =quantum_engine.allocate_qubit()
   H | qubit
   Measure | qubit
   return int(lowerCamelCase_							)


if __name__ == "__main__":
      doctest.testmod()

      # initialises a new quantum backend
      A			:   Dict			=      projectq.MainEngine()

      # Generate a list of 10 random numbers
      A			:   Dict			=      [get_random_number(quantum_engine) for _ in range(10)]

      # Flushes the quantum engine from memory
      quantum_engine.flush()

      print("""Random numbers""", random_numbers_list)





