<jupyter_start><jupyter_text>When we throw 2 classical dice (values on each side from 1 to 6) we have 36 (6 * 6) different results.We want to know the probability of having the sum of the results equals to 11. For that result we have only the combination of 6 and 5. So we will have two events: {5, 6} and {6, 5}So the probability for that result will be:P(11, 2) = 2/(6*6) = 1/18    (The two is because we have 2 dice)Now, we want to calculate the probability of having the sum equals to 8. The combinations for that result will be the following: {4,4}, {3,5}, {5,3}, {2,6}, {6,2} with a total of five combinations.P(8, 2) = 5/36 Things may be more complicated if we have more dices and sum values higher.We want to know the probability of having the sum equals to 8 but having 3 dice.Now the combinations and corresponding events are:{2,3,3}, {3,2,3}, {3,3,2}{2,2,4}, {2,4,2}, {4,2,2}{1,3,4}, {1,4,3}, {3,1,4}, {4,1,3}, {3,4,1}, {4,3,1}{1,2,5}, {1,5,2}, {2,1,5}, {5,1,2}, {2,5,1}, {5,2,1}{1,1,6}, {1,6,1}, {6,1,1}A total amount of 21 different combinationsSo the probability is:P(8, 3) = 21/(6*6*6) = 0.09722222222222222Summarizing the cases we have seen with a function that receives the two argumentsrolldice_sum_prob(11, 2) == 0.0555555555  or 1/18rolldice_sum_prob(8, 2) ==  0.13888888889 or 5/36rolldice_sum_prob(8, 3) == 0.0972222222222   or 7/72And think why we have this result:rolldice_sum_prob(22, 3) == 0Create the function rolldice_sum_prob() for this calculation.Have a nice time!(You do not have to round the results)<jupyter_code>def rolldice_sum_prob(sum_, dice_amount):
    import itertools
    combinations = list(itertools.product(range(1,7),repeat=dice_amount))
    correct = sum(list(map(lambda x: sum(x) == sum_, combinations))) / len(combinations)
    return correct
rolldice_sum_prob(11, 2) # 0.055555555555<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13419216317767044, 'fraction_numerical': 0.11164787976382179, 'mean_word_length': 5.151815181518152, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 5, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '461502', 'license': 'MIT', 'n_tokens_mistral': 763, 'n_tokens_neox': 673, 'n_words': 243, 'path': 'kata-5/Probabilities for Sums in Rolling Cubic Dice.ipynb', 'repo_name': 'David-van-der-Hoeven/codewars', 'size': '1863'}