

"""simple docstring"""





from __future__ import annotations

from collections.abc import Iterator
from typing import Any




class 					_lowerCAmelCase  :







 """simple docstring"""







 def __init__(			self							:			List[str],					UpperCAmelCase__							:			Any	):
    __lowercase								=						data
    __lowercase								=						None







class 					_lowerCAmelCase  :







 """simple docstring"""







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


 def __iter__(			self							:			List[Any]	):
    __lowercase								=						self.head
    while self.head:
       yield node.data
       __lowercase								=						node.next
       if node == self.head:
          break


 def __len__(			self							:			Union[str, Any]	):
    return sum(1 for _ in self	)


 def __repr__(			self							:			List[str]	):
    return "->".join(str(UpperCAmelCase__	) for item in iter(self	)	)


 def 					_lowercase (			self							:			Optional[int],					UpperCAmelCase__							:			Any	):
    self.insert_nth(len(self	),					UpperCAmelCase__	)


 def 					_lowercase (			self							:			Union[str, Any],					UpperCAmelCase__							:			Any	):
    self.insert_nth(0,					UpperCAmelCase__	)


 def 					_lowercase (			self							:			str,					UpperCAmelCase__							:			int,					UpperCAmelCase__							:			Any	):
    if index < 0 or index > len(self	):
       raise IndexError("list index out of range."	)
    __lowercase								=						Node(UpperCAmelCase__	)
    if self.head is None:
       __lowercase								=						new_node  # first node points itself
       __lowercase								=						__lowercase								=						new_node
    elif index == 0:  # insert at head
       __lowercase								=						self.head
       __lowercase								=						__lowercase								=						new_node
    else:
       __lowercase								=						self.head
       for _ in range(index - 1	):
          __lowercase								=						temp.next
       __lowercase								=						temp.next
       __lowercase								=						new_node
       if index == len(self	) - 1:  # insert at tail
          __lowercase								=						new_node


 def 					_lowercase (			self							:			List[Any]	):
    return self.delete_nth(0	)


 def 					_lowercase (			self							:			List[Any]	):
    return self.delete_nth(len(self	) - 1	)


 def 					_lowercase (			self							:			List[str],					UpperCAmelCase__							:			int = 0	):
    if not 0 <= index < len(self	):
       raise IndexError("list index out of range."	)
    __lowercase								=						self.head
    if self.head == self.tail:  # just one node
       __lowercase								=						__lowercase								=						None
    elif index == 0:  # delete head node
       __lowercase								=						self.tail.next.next
       __lowercase								=						self.head.next
    else:
       __lowercase								=						self.head
       for _ in range(index - 1	):
          __lowercase								=						temp.next
       __lowercase								=						temp.next
       __lowercase								=						temp.next.next
       if index == len(self	) - 1:  # delete at tail
          __lowercase								=						temp
    return delete_node.data



 def 					_lowercase (			self							:			Optional[Any]	):
    return len(self	) == 0







def   _A  (  )	->						None:
   '''simple docstring'''


   __lowercase								=						CircularLinkedList()
   assert len(UpperCamelCase_) == 0
   assert circular_linked_list.is_empty() is True
   assert str(UpperCamelCase_) == ""

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

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

   try:
      circular_linked_list.delete_nth(-1)
      raise AssertionError
   except IndexError:
      assert True

   try:
      circular_linked_list.delete_nth(0)
      raise AssertionError
   except IndexError:
      assert True

   assert circular_linked_list.is_empty() is True
   for i in range(5):
      assert len(UpperCamelCase_) == i
      circular_linked_list.insert_nth(UpperCamelCase_,			i + 1)
   assert str(UpperCamelCase_) == "->".join(str(UpperCamelCase_) for i in range(1,			6))

   circular_linked_list.insert_tail(6)
   assert str(UpperCamelCase_) == "->".join(str(UpperCamelCase_) for i in range(1,			7))
   circular_linked_list.insert_head(0)
   assert str(UpperCamelCase_) == "->".join(str(UpperCamelCase_) for i in range(0,			7))

   assert circular_linked_list.delete_front() == 0
   assert circular_linked_list.delete_tail() == 6
   assert str(UpperCamelCase_) == "->".join(str(UpperCamelCase_) for i in range(1,			6))
   assert circular_linked_list.delete_nth(2) == 3

   circular_linked_list.insert_nth(2,			3)
   assert str(UpperCamelCase_) == "->".join(str(UpperCamelCase_) for i in range(1,			6))

   assert circular_linked_list.is_empty() is False


if __name__ == "__main__":
   import doctest

   doctest.testmod()







"""simple docstring"""





def   _A  (  UpperCamelCase_     :       list[int])	->						float:
   '''simple docstring'''


   if not nums:  # Makes sure that the list is not empty
      raise ValueError("List is empty")

   __lowercase								=						sum(UpperCamelCase_) / len(UpperCamelCase_)  # Calculate the average
   return sum(abs(x - average) for x in nums) / len(UpperCamelCase_)


if __name__ == "__main__":
   import doctest

   doctest.testmod()




