

'''simple docstring'''





from __future__ import annotations

from collections.abc import Iterator
from typing import Any





class 		__SCREAMING_SNAKE_CASE							:







				def __init__(       self     :		Optional[int]		,					UpperCAmelCase__     :		Any   ):
										'''simple docstring'''
										lowercase :							Any    		=data
										lowercase :							Node | None    		=None





class 		__SCREAMING_SNAKE_CASE							:







				def __init__(       self     :		List[str]   ):
										'''simple docstring'''
										lowercase :							List[str]    		=None
										lowercase :							str    		=None







				def __iter__(       self     :		Optional[int]   ):
										'''simple docstring'''
										lowercase :							List[Any]    		=self.head
										while self.head:
																yield node.data
																lowercase :							Dict    		=node.next
																if node == self.head:
																						break







				def __len__(       self     :		List[Any]   ):
										'''simple docstring'''
										return sum(1 for _ in self   )







				def __repr__(       self     :		Optional[Any]   ):
										'''simple docstring'''
										return "->".join(str(UpperCAmelCase__   ) for item in iter(self   )   )







				def  lowerCamelCase_	(       self     :		List[str]		,					UpperCAmelCase__     :		Any   ):
										'''simple docstring'''
										self.insert_nth(len(self   )		,					UpperCAmelCase__   )







				def  lowerCamelCase_	(       self     :		Optional[int]		,					UpperCAmelCase__     :		Any   ):
										'''simple docstring'''
										self.insert_nth(0		,					UpperCAmelCase__   )







				def  lowerCamelCase_	(       self     :		List[str]		,					UpperCAmelCase__     :		int		,					UpperCAmelCase__     :		Any   ):
										'''simple docstring'''
										if index < 0 or index > len(self   ):
																raise IndexError('''list index out of range.'''   )
										lowercase :							List[Any]    		=Node(UpperCAmelCase__   )
										if self.head is None:
																lowercase :							Optional[int]    		=new_node  # first node points itself
																lowercase :							Union[str, Any]    		=new_node
										elif index == 0:  # insert at head
																lowercase :							int    		=self.head
																lowercase :							List[str]    		=new_node
										else:
																lowercase :							List[str]    		=self.head
																for _ in range(index - 1   ):
																						lowercase :							Optional[int]    		=temp.next
																lowercase :							str    		=temp.next
																lowercase :							List[Any]    		=new_node
																if index == len(self   ) - 1:  # insert at tail
																						lowercase :							str    		=new_node







				def  lowerCamelCase_	(       self     :		Dict   ):
										'''simple docstring'''
										return self.delete_nth(0   )







				def  lowerCamelCase_	(       self     :		Any   ):
										'''simple docstring'''
										return self.delete_nth(len(self   ) - 1   )







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







				def  lowerCamelCase_	(       self     :		Any   ):
										'''simple docstring'''
										return len(self   ) == 0






def 				_lowerCAmelCase			(   )				->  None:
						lowercase :							Optional[int]    		=CircularLinkedList()
						assert len(__magic_name__						) == 0
						assert circular_linked_list.is_empty() is True
						assert str(__magic_name__						) == ""

						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(__magic_name__						) == i
												circular_linked_list.insert_nth(__magic_name__   , i + 1						)
						assert str(__magic_name__						) == "->".join(str(__magic_name__						) for i in range(1   , 6						)						)

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

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

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

						assert circular_linked_list.is_empty() is False


if __name__ == "__main__":
							import doctest

							doctest.testmod()








'''simple docstring'''





from __future__ import annotations






def 				_lowerCAmelCase			(   __magic_name__						:     list[float]						)				->  float:
						lowercase :							Any    		=0.0_0
						lowercase :							Tuple    		=0
						for resistor in resistors:
												if resistor <= 0:
																		lowercase :							Dict    		=f'''Resistor at index {index} has a negative or zero value!'''
																		raise ValueError(__magic_name__						)
												first_sum += 1 / float(__magic_name__						)
												index += 1
						return 1 / first_sum






def 				_lowerCAmelCase			(   __magic_name__						:     list[float]						)				->  float:
						lowercase :							Optional[Any]    		=0.0_0
						lowercase :							int    		=0
						for resistor in resistors:
												sum_r += resistor
												if resistor < 0:
																		lowercase :							Tuple    		=f'''Resistor at index {index} has a negative value!'''
																		raise ValueError(__magic_name__						)
												index += 1
						return sum_r


if __name__ == "__main__":
							import doctest

							doctest.testmod()





