



class      snake_case__       :







						"""simple docstring"""




						def __init__(     self      ,     __lowercase						)      ->   int:
									"""simple docstring"""




									a__     :		str		 =						data
									a__     :		Optional[int]		 =						None
									a__     :		int		 =						None

						def __str__(     self						)      ->   Any:
									"""simple docstring"""




									return F'''{self.data}'''




class      snake_case__       :







						"""simple docstring"""




						def __init__(     self						)      ->   Union[str, Any]:
									"""simple docstring"""




									a__     :		Union[str, Any]		 =						None
									a__     :		int		 =						None

						def __iter__(     self						)      ->   List[Any]:
									"""simple docstring"""




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

						def __str__(     self						)      ->   Optional[Any]:
									"""simple docstring"""




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

						def __len__(     self						)      ->   Any:
									"""simple docstring"""




									return sum(1 for _ in self						)

						def 							SCREAMING_SNAKE_CASE__(     self      ,     __lowercase						)      ->   List[str]:
									"""simple docstring"""




									self.insert_at_nth(0      ,     __lowercase						)

						def 							SCREAMING_SNAKE_CASE__(     self      ,     __lowercase						)      ->   Any:
									"""simple docstring"""




									self.insert_at_nth(len(self						)      ,     __lowercase						)

						def 							SCREAMING_SNAKE_CASE__(     self      ,     __lowercase      ,     __lowercase						)      ->   int:
									"""simple docstring"""




									a__     :		Union[str, Any]		 =						len(self						)

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

						def 							SCREAMING_SNAKE_CASE__(     self						)      ->   Any:
									"""simple docstring"""




									return self.delete_at_nth(0						)

						def 							SCREAMING_SNAKE_CASE__(     self						)      ->   int:
									"""simple docstring"""




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

						def 							SCREAMING_SNAKE_CASE__(     self      ,     __lowercase						)      ->   Union[str, Any]:
									"""simple docstring"""




									a__     :		int		 =						len(self						)

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

						def 							SCREAMING_SNAKE_CASE__(     self      ,     __lowercase						)      ->   str:
									"""simple docstring"""




									a__     :		Tuple		 =						self.head

									while current.data != data:  # Find the position to delete
												if current.next:
															a__     :		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
												a__     :		int		 =						current.next  # 1 --> 3
												a__     :		Dict		 =						current.previous  # 1 <--> 3
									return data

						def 							SCREAMING_SNAKE_CASE__(     self						)      ->   str:
									"""simple docstring"""




									return len(self						) == 0




def 			lowerCAmelCase_  (						)							-> None:







			"""simple docstring"""
			a__     :		str		 =						DoublyLinkedList()
			assert linked_list.is_empty() is True
			assert str(_lowercase) == ""

			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(_lowercase) == i
						linked_list.insert_at_nth(_lowercase		,     i + 1)
			assert str(_lowercase) == "->".join(str(_lowercase) for i in range(1		,     11))

			linked_list.insert_at_head(0)
			linked_list.insert_at_tail(11)
			assert str(_lowercase) == "->".join(str(_lowercase) 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(_lowercase) == 9
			assert str(_lowercase) == "->".join(str(_lowercase) for i in range(1		,     10))


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

		testmod()









def 			lowerCAmelCase_  (						_lowercase       :     list)							-> bool:







			"""simple docstring"""
			if not isinstance(_lowercase		,     _lowercase):
						raise ValueError("""Input series is not valid, valid series - [1, 2/3, 2]""")
			if len(_lowercase) == 0:
						raise ValueError("""Input list must be a non empty list""")
			if len(_lowercase) == 1 and series[0] != 0:
						return True
			a__     :		Tuple		 =						[]
			a__     :		Union[str, Any]		 =						len(_lowercase)
			for i in range(0		,     _lowercase):
						if series[i] == 0:
									raise ValueError("""Input series cannot have 0 as an element""")
						rec_series.append(1 / series[i])
			a__     :		Dict		 =						rec_series[1] - rec_series[0]
			for index in range(2		,     _lowercase):
						if rec_series[index] - rec_series[index - 1] != common_diff:
									return False
			return True

def 			lowerCAmelCase_  (						_lowercase       :     list)							-> float:







			"""simple docstring"""
			if not isinstance(_lowercase		,     _lowercase):
						raise ValueError("""Input series is not valid, valid series - [2, 4, 6]""")
			if len(_lowercase) == 0:
						raise ValueError("""Input list must be a non empty list""")
			a__     :		Optional[Any]		 =						0
			for val in series:
						answer += 1 / val
			return len(_lowercase) / answer


if __name__ == "__main__":
		import doctest

		doctest.testmod()




