






"""simple docstring"""




from typing import Any






class        UpperCamelCase			:


 def __init__(     self		:						List[str]							,						UpperCAmelCase__		:						Any							)					->       List[Any]:
   _a  :       int             =	data
   _a  :       List[str]             =	None







 def __repr__(     self		:						Union[str, Any]							)					->       str:
   return f"""Node({self.data})"""







class        UpperCamelCase			:


 def __init__(     self		:						Dict							)					->       Optional[int]:
   _a  :       int             =	None


 def __iter__(     self		:						Optional[int]							)					->       Any:
   _a  :       List[Any]             =	self.head
   while node:
     yield node.data
     _a  :       Dict             =	node.next


 def __len__(     self		:						Optional[Any]							)					->       int:
   return sum(1 for _ in self							)


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


 def __getitem__(     self		:						int							,						UpperCAmelCase__		:						int							)					->       Any:
   if not 0 <= index < len(self							):
     raise ValueError("""list index out of range."""							)
   for i, node in enumerate(self							):
     if i == index:
       return node
   return None


 def __setitem__(     self		:						Tuple							,						UpperCAmelCase__		:						int							,						UpperCAmelCase__		:						Any							)					->       None:
   if not 0 <= index < len(self							):
     raise ValueError("""list index out of range."""							)
   _a  :       Optional[int]             =	self.head
   for _ in range(UpperCAmelCase__							):
     _a  :       Any             =	current.next
   _a  :       Optional[int]             =	data


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


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


 def _lowercase	(     self		:						Union[str, Any]							,						UpperCAmelCase__		:						int							,						UpperCAmelCase__		:						Any							)					->       None:
   if not 0 <= index <= len(self							):
     raise IndexError("""list index out of range"""							)
   _a  :       Dict             =	Node(UpperCAmelCase__							)
   if self.head is None:
     _a  :       Dict             =	new_node
   elif index == 0:
     _a  :       str             =	self.head  # link new_node to head
     _a  :       List[Any]             =	new_node
   else:
     _a  :       Dict             =	self.head
     for _ in range(index - 1							):
       _a  :       Optional[int]             =	temp.next
     _a  :       Union[str, Any]             =	temp.next
     _a  :       Optional[Any]             =	new_node


 def _lowercase	(     self		:						str							)					->       None:  # print every node data
   print(self							)


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


 def _lowercase	(     self		:						Union[str, Any]							)					->       Any:  # delete from tail
   return self.delete_nth(len(self							) - 1							)


 def _lowercase	(     self		:						str							,						UpperCAmelCase__		:						int = 0							)					->       Any:
   if not 0 <= index <= len(self							) - 1:  # test if index is valid
     raise IndexError("""List index out of range."""							)
   _a  :       int             =	self.head  # default first node
   if index == 0:
     _a  :       Union[str, Any]             =	self.head.next
   else:
     _a  :       Tuple             =	self.head
     for _ in range(index - 1							):
       _a  :       int             =	temp.next
     _a  :       List[Any]             =	temp.next
     _a  :       Optional[int]             =	temp.next.next
   return delete_node.data


 def _lowercase	(     self		:						Optional[Any]							)					->       bool:
   return self.head is None







 def _lowercase	(     self		:						List[str]							)					->       None:
   _a  :       Optional[Any]             =	None
   _a  :       Any             =	self.head

   while current:
     # Store the current node's next node.
     _a  :       Dict             =	current.next
     # Make the current node's next point backwards
     _a  :       Optional[int]             =	prev
     # Make the previous node be the current node
     _a  :       Union[str, Any]             =	current
     # Make the current node the next node (to progress iteration)
     _a  :       Dict             =	next_node
   # Return prev in order to put the head at the end
   _a  :       List[str]             =	prev







def 			lowerCAmelCase__     (     ):



  '''simple docstring'''
  _a  :       int             =	LinkedList()
  assert linked_list.is_empty() is True
  assert str(UpperCamelCase__				) == ""

  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(1_0				):
    assert len(UpperCamelCase__				) == i
    linked_list.insert_nth(UpperCamelCase__     ,   i + 1				)
  assert str(UpperCamelCase__				) == "->".join(str(UpperCamelCase__				) for i in range(1     ,   1_1				)				)

  linked_list.insert_head(0				)
  linked_list.insert_tail(1_1				)
  assert str(UpperCamelCase__				) == "->".join(str(UpperCamelCase__				) for i in range(0     ,   1_2				)				)

  assert linked_list.delete_head() == 0
  assert linked_list.delete_nth(9				) == 1_0
  assert linked_list.delete_tail() == 1_1
  assert len(UpperCamelCase__				) == 9
  assert str(UpperCamelCase__				) == "->".join(str(UpperCamelCase__				) for i in range(1     ,   1_0				)				)

  assert all(linked_list[i] == i + 1 for i in range(0     ,   9				)				) is True

  for i in range(0     ,   9				):
    _a  :       Optional[int]             =	-i
  assert all(linked_list[i] == -i for i in range(0     ,   9				)				) is True

  linked_list.reverse()
  assert str(UpperCamelCase__				) == "->".join(str(UpperCamelCase__				) for i in range(-8     ,   1				)				)

def 			lowerCAmelCase__     (     ):



  '''simple docstring'''
  _a  :       List[str]             =	[
      -9,
      1_0_0,
      Node(7_7_3_4_5_1_1_2				),
      """dlrow olleH""",
      7,
      5_5_5_5,
      0,
      -192.55_555,
      """Hello, world!""",
      77.9,
      Node(1_0				),
      None,
      None,
      12.20,
  ]
  _a  :       Any             =	LinkedList()

  for i in test_input:
    linked_list.insert_tail(UpperCamelCase__				)

  # Check if it's empty or not
  assert linked_list.is_empty() is False
  assert (
      str(UpperCamelCase__				) == "-9->100->Node(77345112)->dlrow olleH->7->5555->0->"
      "-192.55555->Hello, world!->77.9->Node(10)->None->None->12.2"
  )

  # Delete the head
  _a  :       str             =	linked_list.delete_head()
  assert result == -9
  assert (
      str(UpperCamelCase__				) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
      "Hello, world!->77.9->Node(10)->None->None->12.2"
  )

  # Delete the tail
  _a  :       Optional[int]             =	linked_list.delete_tail()
  assert result == 12.2
  assert (
      str(UpperCamelCase__				) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
      "Hello, world!->77.9->Node(10)->None->None"
  )

  # Delete a node in specific location in linked list
  _a  :       List[str]             =	linked_list.delete_nth(1_0				)
  assert result is None
  assert (
      str(UpperCamelCase__				) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
      "Hello, world!->77.9->Node(10)->None"
  )

  # Add a Node instance to its head
  linked_list.insert_head(Node("""Hello again, world!"""				)				)
  assert (
      str(UpperCamelCase__				)
      == "Node(Hello again, world!)->100->Node(77345112)->dlrow olleH->"
      "7->5555->0->-192.55555->Hello, world!->77.9->Node(10)->None"
  )

  # Add None to its tail
  linked_list.insert_tail(UpperCamelCase__				)
  assert (
      str(UpperCamelCase__				)
      == "Node(Hello again, world!)->100->Node(77345112)->dlrow olleH->"
      "7->5555->0->-192.55555->Hello, world!->77.9->Node(10)->None->None"
  )

  # Reverse the linked list
  linked_list.reverse()
  assert (
      str(UpperCamelCase__				)
      == "None->None->Node(10)->77.9->Hello, world!->-192.55555->0->5555->"
      "7->dlrow olleH->Node(77345112)->100->Node(Hello again, world!)"
  )

def 			lowerCAmelCase__     (     ):



  '''simple docstring'''
  from doctest import testmod

  testmod()

  _a  :       str             =	LinkedList()
  linked_list.insert_head(input("""Inserting 1st at head """				).strip()				)
  linked_list.insert_head(input("""Inserting 2nd at head """				).strip()				)
  print("""\nPrint list:"""				)
  linked_list.print_list()
  linked_list.insert_tail(input("""\nInserting 1st at tail """				).strip()				)
  linked_list.insert_tail(input("""Inserting 2nd at tail """				).strip()				)
  print("""\nPrint list:"""				)
  linked_list.print_list()
  print("""\nDelete head"""				)
  linked_list.delete_head()
  print("""Delete tail"""				)
  linked_list.delete_tail()
  print("""\nPrint list:"""				)
  linked_list.print_list()
  print("""\nReverse linked list"""				)
  linked_list.reverse()
  print("""\nPrint list:"""				)
  linked_list.print_list()
  print("""\nString representation of linked list:"""				)
  print(UpperCamelCase__				)
  print("""\nReading/changing Node data using indexing:"""				)
  print(F"""Element at Position 1: {linked_list[1]}"""				)
  _a  :       Dict             =	input("""Enter New Value: """				).strip()
  print("""New list:"""				)
  print(UpperCamelCase__				)
  print(F"""length of linked_list is : {len(UpperCamelCase__				)}"""				)


if __name__ == "__main__":
 main()









"""simple docstring"""




def 			lowerCAmelCase__     (     UpperCamelCase__     ,   UpperCamelCase__				):



  '''simple docstring'''

  # Check if the input is valid
  if not len(UpperCamelCase__				) == len(UpperCamelCase__				) == 3:
    raise ValueError("""Please enter a valid equation."""				)
  if equationa[0] == equationa[1] == equationa[0] == equationa[1] == 0:
    raise ValueError("""Both a & b of two equations can't be zero."""				)

  # Extract the coefficients
  _a      ,  _a      ,  _a  :       Any             =	equationa
  _a      ,  _a      ,  _a  :       Tuple             =	equationa

  # Calculate the determinants of the matrices
  _a  :       int             =	aa * ba - aa * ba
  _a  :       str             =	ca * ba - ca * ba
  _a  :       str             =	aa * ca - aa * ca

  # Check if the system of linear equations has a solution (using Cramer's rule)
  if determinant == 0:
    if determinant_x == determinant_y == 0:
      raise ValueError("""Infinite solutions. (Consistent system)"""				)
    else:
      raise ValueError("""No solution. (Inconsistent system)"""				)
  else:
    if determinant_x == determinant_y == 0:
      # Trivial solution (Inconsistent system)
      return (0.0, 0.0)
    else:
      _a  :       Dict             =	determinant_x / determinant
      _a  :       str             =	determinant_y / determinant
      # Non-Trivial Solution (Consistent system)
      return (x, y)

