





"""simple docstring"""






from importlib import import_module

from .logging import get_logger


lowerCAmelCase_			=							get_logger(__name__)



class 	lowerCAmelCase					:

       '''simple docstring'''





       def __init__(   self    ,  a__    ,  a__=None     ):
              _UpperCAmelCase     =     attrs or []
              if module is not None:
                     for key in module.__dict__:
                            if key in attrs or not key.startswith('__'     ):
                                   setattr(self    ,  a__    ,  getattr(a__    ,  a__     )     )
              _UpperCAmelCase     =     module._original_module if isinstance(a__    ,  _PatchedModuleObj     ) else module



class 	lowerCAmelCase					:

       '''simple docstring'''





       lowerCAmelCase__						 =  []






       def __init__(   self    ,  a__    ,  a__    ,  a__    ,  a__=None     ):
              _UpperCAmelCase     =     obj
              _UpperCAmelCase     =     target
              _UpperCAmelCase     =     new
              _UpperCAmelCase     =     target.split('.'     )[0]
              _UpperCAmelCase     =     {}
              _UpperCAmelCase     =     attrs or []






       def __enter__(   self     ):
              *_UpperCAmelCase    ,							_UpperCAmelCase     =     self.target.split('.'     )

              # Patch modules:
              # it's used to patch attributes of submodules like "os.path.join";
              # in this case we need to patch "os" and "os.path"

              for i in range(len(a__     )     ):
                     try:
                            _UpperCAmelCase     =     import_module('.'.join(submodules[: i + 1]     )     )
                     except ModuleNotFoundError:
                            continue
                     # We iterate over all the globals in self.obj in case we find "os" or "os.path"
                     for attr in self.obj.__dir__():
                            _UpperCAmelCase     =     getattr(self.obj    ,  a__     )
                            # We don't check for the name of the global, but rather if its value *is* "os" or "os.path".
                            # This allows to patch renamed modules like "from os import path as ospath".
                            if obj_attr is submodule or (
                                (isinstance(a__    ,  _PatchedModuleObj     ) and obj_attr._original_module is submodule)
                            ):
                                   _UpperCAmelCase     =     obj_attr
                                   # patch at top level
                                   setattr(self.obj    ,  a__    ,  _PatchedModuleObj(a__    ,  attrs=self.attrs     )     )
                                   _UpperCAmelCase     =     getattr(self.obj    ,  a__     )
                                   # construct lower levels patches
                                   for key in submodules[i + 1 :]:
                                          setattr(a__    ,  a__    ,  _PatchedModuleObj(getattr(a__    ,  a__    ,  a__     )    ,  attrs=self.attrs     )     )
                                          _UpperCAmelCase     =     getattr(a__    ,  a__     )
                                   # finally set the target attribute
                                   setattr(a__    ,  a__    ,  self.new     )

        # Patch attribute itself:
        # it's used for builtins like "open",
        # and also to patch "os.path.join" we may also need to patch "join"
        # itself if it was imported as "from os.path import join".

              if submodules:  # if it's an attribute of a submodule like "os.path.join"
                     try:
                            _UpperCAmelCase     =     getattr(import_module('.'.join(a__     )     )    ,  a__     )
                     except (AttributeError, ModuleNotFoundError):
                            return
                     # We iterate over all the globals in self.obj in case we find "os.path.join"
                     for attr in self.obj.__dir__():
                            # We don't check for the name of the global, but rather if its value *is* "os.path.join".
                            # This allows to patch renamed attributes like "from os.path import join as pjoin".
                            if getattr(self.obj    ,  a__     ) is attr_value:
                                   _UpperCAmelCase     =     getattr(self.obj    ,  a__     )
                                   setattr(self.obj    ,  a__    ,  self.new     )
              elif target_attr in globals()["__builtins__"]:  # if it'a s builtin like "open"
                     _UpperCAmelCase     =     globals()['__builtins__'][target_attr]
                     setattr(self.obj    ,  a__    ,  self.new     )
              else:
                     raise RuntimeError(f"""Tried to patch attribute {target_attr} instead of a submodule."""     )






       def __exit__(   self    ,  *a__     ):
              for attr in list(self.original     ):
                     setattr(self.obj    ,  a__    ,  self.original.pop(a__     )     )






       def 							__A (   self     ):
              self.__enter__()
              self._active_patches.append(self     )






       def 							__A (   self     ):
              try:
                     self._active_patches.remove(self     )
              except ValueError:
                     # If the patch hasn't been started this will fail
                     return None

              return self.__exit__()













"""simple docstring"""






from itertools import product

def       __lowerCamelCase    (       SCREAMING_SNAKE_CASE,SCREAMING_SNAKE_CASE							)		->       list[int]:






       """simple docstring"""




       _UpperCAmelCase     =     sides_number
       _UpperCAmelCase     =     max_face_number * dice_number
       _UpperCAmelCase     =     [0] * (max_total + 1)

       _UpperCAmelCase     =     1
       _UpperCAmelCase     =     range(SCREAMING_SNAKE_CASE,max_face_number + 1							)
       for dice_numbers in product(SCREAMING_SNAKE_CASE,repeat=SCREAMING_SNAKE_CASE							):
              _UpperCAmelCase     =     sum(SCREAMING_SNAKE_CASE							)
              totals_frequencies[total] += 1

       return totals_frequencies

def       __lowerCamelCase    (       )		->       float:






       """simple docstring"""




       _UpperCAmelCase     =     total_frequency_distribution(
           sides_number=4,dice_number=9							)
       _UpperCAmelCase     =     total_frequency_distribution(
           sides_number=6,dice_number=6							)

       _UpperCAmelCase     =     0
       _UpperCAmelCase     =     9
       _UpperCAmelCase     =     4 * 9
       _UpperCAmelCase     =     6
       for peter_total in range(SCREAMING_SNAKE_CASE,max_peter_total + 1							):
              peter_wins_count += peter_totals_frequencies[peter_total] * sum(
                  colin_totals_frequencies[min_colin_total:peter_total]							)

       _UpperCAmelCase     =     (4**9) * (6**6)
       _UpperCAmelCase     =     peter_wins_count / total_games_number

       _UpperCAmelCase     =     round(SCREAMING_SNAKE_CASE,ndigits=7							)

       return rounded_peter_win_probability


if __name__ == "__main__":
    print(F'''{solution() = }''')






