§
    OŠtj÷  ã                   óF   — d dl mZ d dlmZmZ d dlmZ d	d„Zd
d„Z	d
d„ZdS )é    )Údefaultdict)ÚmultisetÚis_palindromic)Úas_inté
   Nc                 ó  — t          |¦  «        }t          | ¦  «        } |dk     rt          d¦  «        ‚t          | ¦  «        g }}||k    r.t          ||¦  «        \  }}|                     |¦  «         ||k    °.|                     |¦  «         |                     | dk     r| n|¦  «         |                     ¦   «          t          |¦  «        dz
  }|�0||k    rt          d| ›d|›d�¦  «        ‚||k     rdg||z
  z  |dd…<   |S )	a  
    Return a list of the digits of ``n`` in base ``b``. The first
    element in the list is ``b`` (or ``-b`` if ``n`` is negative).

    Examples
    ========

    >>> from sympy.ntheory.digits import digits
    >>> digits(35)
    [10, 3, 5]

    If the number is negative, the negative sign will be placed on the
    base (which is the first element in the returned list):

    >>> digits(-35)
    [-10, 3, 5]

    Bases other than 10 (and greater than 1) can be selected with ``b``:

    >>> digits(27, b=2)
    [2, 1, 1, 0, 1, 1]

    Use the ``digits`` keyword if a certain number of digits is desired:

    >>> digits(35, digits=4)
    [10, 0, 0, 3, 5]

    Parameters
    ==========

    n: integer
        The number whose digits are returned.

    b: integer
        The base in which digits are computed.

    digits: integer (or None for all digits)
        The number of digits to be returned (padded with zeros, if
        necessary).

    See Also
    ========
    sympy.core.intfunc.num_digits, count_digits
    é   zb must be greater than 1r   é   NzFor z, at least z digits are needed.)r   Ú
ValueErrorÚabsÚdivmodÚappendÚreverseÚlen)ÚnÚbÚdigitsÚxÚyÚrÚndigs          úR/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/ntheory/digits.pyr   r      s  € õ\ 	ˆq‰	Œ	€AÝˆq‰	Œ	€AØˆ1‚u€uÝÐ3Ñ4Ô4Ð4å�1‰vŒv�rˆ1ˆØ�1ŠfˆfÝ˜!˜Q‘<”<‰DˆAˆqØ�HŠH�Q‰KŒKˆKð �1Šfˆfð 	
�Š�‰ŒˆØ	�Š�q˜1’u�u�!�� !Ñ$Ô$Ð$Ø	�	Š	‰ŒˆÝ�1‰vŒv˜‰zˆØÐØ�fŠ}ˆ}Ý �jØ@AÀÀÀ4À4À4ÐHñJô Jð Jà˜’�Ø˜˜f t™mÑ,��!�A�#‘Øˆó    c           	      óè   — t          t          t          t          | |¦  «        ¦  «                             ¦   «         ¦  «        }||v r|                     |¦  «        n|                     | ¦  «         |S )a  
    Return a dictionary whose keys are the digits of ``n`` in the
    given base, ``b``, with keys indicating the digits appearing in the
    number and values indicating how many times that digit appeared.

    Examples
    ========

    >>> from sympy.ntheory import count_digits

    >>> count_digits(1111339)
    {1: 4, 3: 2, 9: 1}

    The digits returned are always represented in base-10
    but the number itself can be entered in any format that is
    understood by Python; the base of the number can also be
    given if it is different than 10:

    >>> n = 0xFA; n
    250
    >>> count_digits(_)
    {0: 1, 2: 1, 5: 1}
    >>> count_digits(n, 16)
    {10: 1, 15: 1}

    The default dictionary will return a 0 for any digit that did
    not appear in the number. For example, which digits appear 7
    times in ``77!``:

    >>> from sympy import factorial
    >>> c77 = count_digits(factorial(77))
    >>> [i for i in range(10) if c77[i] == 7]
    [1, 3, 7, 9]

    See Also
    ========
    sympy.core.intfunc.num_digits, digits
    )r   Úintr   r   ÚitemsÚpop)r   r   Úrvs      r   Úcount_digitsr   K   s[   € õN 
•S�(¥6¨!¨Q¡<¤<Ñ0Ô0×6Ò6Ñ8Ô8Ñ	9Ô	9€BØ�b��€B‡F‚Fˆ1�I„I€I˜bŸfšf a R™jœjøØ€Ir   c                 ó>   — t          t          | |¦  «        d¦  «        S )aÆ  return True if ``n`` is the same when read from left to right
    or right to left in the given base, ``b``.

    Examples
    ========

    >>> from sympy.ntheory import is_palindromic

    >>> all(is_palindromic(i) for i in (-11, 1, 22, 121))
    True

    The second argument allows you to test numbers in other
    bases. For example, 88 is palindromic in base-10 but not
    in base-8:

    >>> is_palindromic(88, 8)
    False

    On the other hand, a number can be palindromic in base-8 but
    not in base-10:

    >>> 0o121, is_palindromic(0o121)
    (81, False)

    Or it might be palindromic in both bases:

    >>> oct(121), is_palindromic(121, 8) and is_palindromic(121)
    ('0o171', True)

    r
   )Ú_palindromicr   )r   r   s     r   r   r   w   s   € õ> �˜q !™œ aÑ(Ô(Ð(r   )r   N)r   )
Úcollectionsr   Úsympy.utilities.iterablesr   r   r!   Úsympy.utilities.miscr   r   r   © r   r   ú<module>r&      s�   ðØ #Ð #Ð #Ð #Ð #Ð #à NÐ NÐ NÐ NÐ NÐ NÐ NÐ NØ 'Ð 'Ð 'Ð 'Ð 'Ð 'ðAð Að Að AðH)ð )ð )ð )ðX)ð )ð )ð )ð )ð )r   