



'''simple docstring'''





from itertools import product





def   a_   (		_UpperCAmelCase    :      int ,_UpperCAmelCase    :      int				)    ->  list[int]:
      __snake_case :   Optional[int]													=    sides_number
      __snake_case :   Dict													=    max_face_number * dice_number
      __snake_case :   List[Any]													=    [0] * (max_total + 1)

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

      return totals_frequencies





def   a_   (		)    ->  float:
      __snake_case :   str													=    total_frequency_distribution(
          sides_number=4 ,dice_number=9				)
      __snake_case :   Optional[Any]													=    total_frequency_distribution(
          sides_number=6 ,dice_number=6				)

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

      __snake_case :   Tuple													=    (4**9) * (6**6)
      __snake_case :   List[Any]													=    peter_wins_count / total_games_number

      __snake_case :   Dict													=    round(_UpperCAmelCase ,ndigits=7				)

      return rounded_peter_win_probability


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








'''simple docstring'''





import functools





def   a_   (		_UpperCAmelCase    :      list[int] ,_UpperCAmelCase    :      list[int]				)    ->  int:

      # Validation
      if not isinstance(_UpperCAmelCase ,_UpperCAmelCase				) or not all(isinstance(_UpperCAmelCase ,_UpperCAmelCase				) for day in days				):
            raise ValueError('The parameter days should be a list of integers'				)

      if len(_UpperCAmelCase				) != 3 or not all(isinstance(_UpperCAmelCase ,_UpperCAmelCase				) for cost in costs				):
            raise ValueError('The parameter costs should be a list of three integers'				)

      if len(_UpperCAmelCase				) == 0:
            return 0

      if min(_UpperCAmelCase				) <= 0:
            raise ValueError('All days elements should be greater than 0'				)

      if max(_UpperCAmelCase				) >= 3_66:
            raise ValueError('All days elements should be less than 366'				)

      __snake_case :   str													=    set(_UpperCAmelCase				)

      @functools.cache
      def dynamic_programming(_UpperCAmelCase    :      int				) -> int:
            if index > 3_65:
                  return 0

            if index not in days_set:
                  return dynamic_programming(index + 1				)

            return min(
                costs[0] + dynamic_programming(index + 1				) ,costs[1] + dynamic_programming(index + 7				) ,costs[2] + dynamic_programming(index + 30				) ,)

      return dynamic_programming(1				)


if __name__ == "__main__":
    import doctest

    doctest.testmod()



