






"""simple docstring"""



from __future__ import annotations

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




class        lowerCAmelCase__       :
   SCREAMING_SNAKE_CASE_					      =('''_front''', '''_back''', '''_len''')




   @dataclass
   class        lowerCAmelCase__       :
      SCREAMING_SNAKE_CASE_					      =None
      SCREAMING_SNAKE_CASE_					      =None
      SCREAMING_SNAKE_CASE_					      =None




   class        lowerCAmelCase__       :
      SCREAMING_SNAKE_CASE_					      =('''_cur''',)
      def __init__(						self	:     Optional[Any]				,       snake_case__	:     Deque._Node | None				):


           '''simple docstring'''
           UpperCAmelCase__		:  Optional[Any]				=				cur
      def __iter__(						self	:     Any				):


           '''simple docstring'''
           return self




      def 	__a				(						self	:     Optional[Any]				):


           '''simple docstring'''
           if self._cur is None:
                # finished iterating
                raise StopIteration
           UpperCAmelCase__		:  Optional[Any]				=				self._cur.val
           UpperCAmelCase__		:  Dict				=				self._cur.next_node

           return val




   def __init__(						self	:     Tuple				,       snake_case__	:     Iterable[Any] | None = None				):


        '''simple docstring'''
        UpperCAmelCase__		:  Any				=				None
        UpperCAmelCase__		:  Any				=				None
        UpperCAmelCase__		:  int				=				0

        if iterable is not None:
             # append every value to the deque
             for val in iterable:
                  self.append(snake_case__				)
   def 	__a				(						self	:     int				,       snake_case__	:     Any				):


        '''simple docstring'''
        UpperCAmelCase__		:  Optional[Any]				=				self._Node(snake_case__				,       snake_case__				,       snake_case__				)
        if self.is_empty():
             # front = back
             UpperCAmelCase__		:  Dict				=				node
             UpperCAmelCase__		:  List[str]				=				1
        else:
             # connect nodes
             UpperCAmelCase__		:  Dict				=				node
             UpperCAmelCase__		:  Optional[Any]				=				self._back
             UpperCAmelCase__		:  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 	__a				(						self	:     List[Any]				,       snake_case__	:     Any				):


        '''simple docstring'''
        UpperCAmelCase__		:  int				=				self._Node(snake_case__				,       snake_case__				,       snake_case__				)
        if self.is_empty():
             # front = back
             UpperCAmelCase__		:  Optional[int]				=				node
             UpperCAmelCase__		:  List[str]				=				1
        else:
             # connect nodes
             UpperCAmelCase__		:  Tuple				=				self._front
             UpperCAmelCase__		:  Optional[int]				=				node
             UpperCAmelCase__		:  Tuple				=				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 	__a				(						self	:     Optional[Any]				,       snake_case__	:     Iterable[Any]				):


        '''simple docstring'''
        for val in iterable:
             self.append(snake_case__				)
   def 	__a				(						self	:     str				,       snake_case__	:     Iterable[Any]				):


        '''simple docstring'''
        for val in iterable:
             self.appendleft(snake_case__				)
   def 	__a				(						self	:     Dict				):


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

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

        self._len -= 1

        return topop.val
   def 	__a				(						self	:     Union[str, Any]				):


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

        UpperCAmelCase__		:  Union[str, Any]				=				self._front
        UpperCAmelCase__		:  Any				=				self._front.next_node  # set new front and drop the first node
        UpperCAmelCase__		:  Any				=				None

        self._len -= 1

        return topop.val
   def 	__a				(						self	:     Optional[Any]				):


        '''simple docstring'''
        return self._front is None
   def __len__(						self	:     Optional[int]				):


        '''simple docstring'''
        return self._len
   def __eq__(						self	:     Any				,       snake_case__	:     object				):


        '''simple docstring'''

        if not isinstance(snake_case__				,       snake_case__				):
             return NotImplemented

        UpperCAmelCase__		:  Optional[Any]				=				self._front
        UpperCAmelCase__		:  List[str]				=				other._front

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

        while me is not None and oth is not None:
             # compare every value
             if me.val != oth.val:
                  return False
             UpperCAmelCase__		:  Dict				=				me.next_node
             UpperCAmelCase__		:  Dict				=				oth.next_node

        return True
   def __iter__(						self	:     Tuple				):


        '''simple docstring'''
        return Deque._Iterator(self._front				)




   def __repr__(						self	:     List[Any]				):


        '''simple docstring'''
        UpperCAmelCase__		:  int				=				[]
        UpperCAmelCase__		:  Union[str, Any]				=				self._front
        while aux is not None:
             # append the values in a list to display
             values_list.append(aux.val				)
             UpperCAmelCase__		:  Dict				=				aux.next_node

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


if __name__ == "__main__":
 import doctest

 doctest.testmod()










"""simple docstring"""



from doctest import testmod
from math import sqrt


def      SCREAMING_SNAKE_CASE__    (   snake_case    :      int							)->						list:






     '''simple docstring'''



     UpperCAmelCase__		:  list[int]				=				[]
     if num < 1:
          return facs
     facs.append(1							)
     if num == 1:
          return facs
     facs.append(snake_case							)
     for i in range(2       , int(sqrt(snake_case							)							) + 1							):
          if num % i == 0:  # If i is a factor of num
               facs.append(snake_case							)
               UpperCAmelCase__		:  Any				=				num // i  # num//i is the other factor of num
               if d != i:  # If d and i are distinct
                    facs.append(snake_case							)  # we have found another factor
     facs.sort()
     return facs


if __name__ == "__main__":
 testmod(name="""factors_of_a_number""", verbose=True)


