


from operator import delitem, getitem, setitem

import pytest

from data_structures.hashing.hash_map import HashMap

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : Optional[int]    ):
     return getitem, k

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : str      ,					SCREAMING_SNAKE_CASE__      : Optional[Any]    ):
     return setitem, k, v

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : Union[str, Any]    ):
     return delitem, k

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : Tuple      ,					SCREAMING_SNAKE_CASE__      : str      ,					*SCREAMING_SNAKE_CASE__      : List[Any]    ):
     try:
          return fun(SCREAMING_SNAKE_CASE__      ,					*SCREAMING_SNAKE_CASE__    ), None
     except Exception as e:
          return None, e


_A			=						(
    _set('key_a', 'val_a'),
    _set('key_b', 'val_b'),
)

_A			=						[
    _set('key_a', 'val_a'),
    _set('key_a', 'val_b'),
]

_A			=						[
    _set('key_a', 'val_a'),
    _set('key_b', 'val_b'),
    _del('key_a'),
    _del('key_b'),
    _set('key_a', 'val_a'),
    _del('key_a'),
]

_A			=						[
    _get('key_a'),
    _del('key_a'),
    _set('key_a', 'val_a'),
    _del('key_a'),
    _del('key_a'),
    _get('key_a'),
]

_A			=						[
    *[_set(x, x) for x in range(5)],  # guaranteed upsize
]

_A			=						[
    *[_set(x, x) for x in range(5)],  # guaranteed upsize
    *[_del(x) for x in range(5)],
    _set('key_a', 'val_b'),
]

@pytest.mark.parametrize(
    'operations'      ,					(
        pytest.param(_add_items      ,					id='add items'    ),
        pytest.param(_overwrite_items      ,					id='overwrite items'    ),
        pytest.param(_delete_items      ,					id='delete items'    ),
        pytest.param(_access_absent_items      ,					id='access absent items'    ),
        pytest.param(_add_with_resize_up      ,					id='add with resize up'    ),
        pytest.param(_add_with_resize_down      ,					id='add with resize down'    ),
    )      ,					)
def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : Tuple    ):
     __UpperCamelCase   							=HashMap(initial_block_size=4    )
     __UpperCamelCase   							={}
     for _, (fun, *args) in enumerate(SCREAMING_SNAKE_CASE__    ):
          __UpperCamelCase							,				__UpperCamelCase   							=_run_operation(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__      ,					*SCREAMING_SNAKE_CASE__    )
          __UpperCamelCase							,				__UpperCamelCase   							=_run_operation(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__      ,					*SCREAMING_SNAKE_CASE__    )
          assert my_res == py_res
          assert str(SCREAMING_SNAKE_CASE__    ) == str(SCREAMING_SNAKE_CASE__    )
          assert set(SCREAMING_SNAKE_CASE__    ) == set(SCREAMING_SNAKE_CASE__    )
          assert len(SCREAMING_SNAKE_CASE__    ) == len(SCREAMING_SNAKE_CASE__    )
          assert set(my.items()    ) == set(py.items()    )





def 						_UpperCAmelCase    (      ):
     def is_public(SCREAMING_SNAKE_CASE__      : str    ) -> bool:
          return not name.startswith('_'    )

     __UpperCamelCase   							={name for name in dir({}    ) if is_public(SCREAMING_SNAKE_CASE__    )}
     __UpperCamelCase   							={name for name in dir(HashMap()    ) if is_public(SCREAMING_SNAKE_CASE__    )}

     assert dict_public_names > hash_public_names









from __future__ import annotations

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int    ):
     if b == 0:
          return (1, 0)
     ((__UpperCamelCase)							,				(__UpperCamelCase))   							=extended_euclid(SCREAMING_SNAKE_CASE__      ,					a % b    )
     __UpperCamelCase   							=a // b
     return (y, x - k * y)

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int    ):
     ((__UpperCamelCase)							,				(__UpperCamelCase))   							=extended_euclid(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__    )
     __UpperCamelCase   							=na * na
     __UpperCamelCase   							=ra * x * na + ra * y * na
     return (n % m + m) % m

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int    ):
     ((__UpperCamelCase)							,				(__UpperCamelCase))   							=extended_euclid(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__    )
     if b < 0:
          __UpperCamelCase   							=(b % n + n) % n
     return b

def 						_UpperCAmelCase    (      SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int      ,					SCREAMING_SNAKE_CASE__      : int    ):
     __UpperCamelCase							,				__UpperCamelCase   							=invert_modulo(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__    ), invert_modulo(SCREAMING_SNAKE_CASE__      ,					SCREAMING_SNAKE_CASE__    )
     __UpperCamelCase   							=na * na
     __UpperCamelCase   							=ra * x * na + ra * y * na
     return (n % m + m) % m


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

   testmod(name='chinese_remainder_theorem', verbose=True)
   testmod(name='chinese_remainder_theorem2', verbose=True)
   testmod(name='invert_modulo', verbose=True)
   testmod(name='extended_euclid', verbose=True)





