
from __future__ import annotations

from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any

class __snake_case	:
    _a	:		int=       ("_front", "_back", "_len")

    @dataclass
    class __snake_case	:
        _a	:		Optional[int]=       None
        _a	:		str=       None
        _a	:		List[Any]=       None






    class __snake_case	:
        _a	:		List[Any]=       ("_cur",)
        def __init__(						self	,snake_case   ):



               '''simple docstring'''







               lowercase							:  Optional[Any] 			=   cur
        def __iter__(						self   ):



               '''simple docstring'''







               return self
        def    _SCREAMING_SNAKE_CASE (						self   ):



               '''simple docstring'''







               if self._cur is None:
                      # finished iterating
                      raise StopIteration
               lowercase							:  Dict 			=   self._cur.val
               lowercase							:  List[Any] 			=   self._cur.next_node

               return val






    def __init__(						self	,snake_case = None   ):



           '''simple docstring'''







           lowercase							:  List[str] 			=   None
           lowercase							:  Any 			=   None
           lowercase							:  str 			=   0

           if iterable is not None:
                  # append every value to the deque
                  for val in iterable:
                         self.append(SCREAMING_SNAKE_CASE_   )
    def    _SCREAMING_SNAKE_CASE (						self	,snake_case   ):



           '''simple docstring'''







           lowercase							:  List[Any] 			=   self._Node(SCREAMING_SNAKE_CASE_	,SCREAMING_SNAKE_CASE_	,SCREAMING_SNAKE_CASE_   )
           if self.is_empty():
                  # front = back
                  lowercase							:  int 			=   node
                  lowercase							:  str 			=   1
           else:
                  # connect nodes
                  lowercase							:  int 			=   node
                  lowercase							:  Union[str, Any] 			=   self._back
                  lowercase							:  List[str] 			=   node  # assign new back to the new node

                  self._len += 1

                  # make sure there were no errors
                  assert not self.is_empty(), "Error on appending value."
    def    _SCREAMING_SNAKE_CASE (						self	,snake_case   ):



           '''simple docstring'''







           lowercase							:  Optional[Any] 			=   self._Node(SCREAMING_SNAKE_CASE_	,SCREAMING_SNAKE_CASE_	,SCREAMING_SNAKE_CASE_   )
           if self.is_empty():
                  # front = back
                  lowercase							:  Union[str, Any] 			=   node
                  lowercase							:  Union[str, Any] 			=   1
           else:
                  # connect nodes
                  lowercase							:  List[Any] 			=   self._front
                  lowercase							:  Optional[Any] 			=   node
                  lowercase							:  int 			=   node  # assign new front to the new node

                  self._len += 1

                  # make sure there were no errors
                  assert not self.is_empty(), "Error on appending value."
    def    _SCREAMING_SNAKE_CASE (						self	,snake_case   ):



           '''simple docstring'''







           for val in iterable:
                  self.append(SCREAMING_SNAKE_CASE_   )
    def    _SCREAMING_SNAKE_CASE (						self	,snake_case   ):



           '''simple docstring'''







           for val in iterable:
                  self.appendleft(SCREAMING_SNAKE_CASE_   )
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           assert not self.is_empty(), "Deque is empty."

           lowercase							:  Optional[Any] 			=   self._back
           lowercase							:  Optional[Any] 			=   self._back.prev_node  # set new back
           # drop the last node - python will deallocate memory automatically
           lowercase							:  int 			=   None

           self._len -= 1

           return topop.val
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           assert not self.is_empty(), "Deque is empty."

           lowercase							:  Any 			=   self._front
           lowercase							:  List[str] 			=   self._front.next_node  # set new front and drop the first node
           lowercase							:  Optional[Any] 			=   None

           self._len -= 1

           return topop.val
    def    _SCREAMING_SNAKE_CASE (						self   ):



           '''simple docstring'''







           return self._front is None
    def __len__(						self   ):



           '''simple docstring'''







           return self._len
    def __eq__(						self	,snake_case   ):



           '''simple docstring'''







           if not isinstance(SCREAMING_SNAKE_CASE_	,SCREAMING_SNAKE_CASE_   ):
                  return NotImplemented

           lowercase							:  str 			=   self._front
           lowercase							:  Union[str, Any] 			=   other._front

           # if the length of the dequeues are not the same, they are not equal
           if len(self   ) != len(SCREAMING_SNAKE_CASE_   ):
                  return False

           while me is not None and oth is not None:
                  # compare every value
                  if me.val != oth.val:
                         return False
                  lowercase							:  List[Any] 			=   me.next_node
                  lowercase							:  List[str] 			=   oth.next_node

           return True
    def __iter__(						self   ):



           '''simple docstring'''







           return Deque._Iterator(self._front   )
    def __repr__(						self   ):



           '''simple docstring'''







           lowercase							:  Optional[int] 			=   []
           lowercase							:  Union[str, Any] 			=   self._front
           while aux is not None:
                  # append the values in a list to display
                  values_list.append(aux.val   )
                  lowercase							:  Tuple 			=   aux.next_node

           return f"[{', '.join(repr(SCREAMING_SNAKE_CASE_   ) for val in values_list   )}]"


if __name__ == "__main__":
  import doctest

  doctest.testmod()




from __future__ import annotations







def 		_snake_case(						SCREAMING_SNAKE_CASE__       )				->					bool:
       lowercase							:  int
       lowercase							:  list[str] 			=   list(SCREAMING_SNAKE_CASE__       )
       lowercase			,    lowercase							:  Union[str, Any] 			=   _vector[:-1], int(_vector[-1]       )
       lowercase							:  list[int] 			=   [int(SCREAMING_SNAKE_CASE__       ) for digit in __vector]

       vector.reverse()
       for i, digit in enumerate(SCREAMING_SNAKE_CASE__       ):
              if i & 1 == 0:
                     lowercase							:  int 			=   digit * 2
                     if doubled > 9:
                            doubled -= 9
                     check_digit += doubled
              else:
                     check_digit += digit

       return check_digit % 10 == 0


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  assert is_luhn("""79927398713""")
  assert not is_luhn("""79927398714""")
