The number of possible event results

I need to calculate the possible number of results with detailed screens. details: we have 1 text box in which you need to enter any number from 0 to 7. There are 13 categories of results, but the average value of all results should be equal to the number entered in texbox.

for example: textbox: __ between 1 to 7 __ (if 3) ______.

categories 1: 1, 2, 3 , 4, 5, 6, 7
categories 2: 1, 2, 3, 4 , 5, 6, 7
categories 3: 1, 2 , 3, 4, 5, 6, 7
categories 4: 1, 2, 3 , 4, 5, 6, 7
categories 5: 1, 2, 3 , 4, 5, 6, 7
categories 6: 1, 2, 3 , 4, 5, 6, 7
categories 7: 1, 2, 3 , 4, 5, 6, 7
categories 8: 1, 2, 3 , 4, 5, 6, 7
categories 9: 1, 2, 3 , 4, 5, 6, 7
categories 10: 1, 2, 3 , 4, 5, 6, 7
categories 11: 1, 2, 3 , 4, 5, 6, 7
categories 12: 1, 2, 3 , 4, 5, 6, 7
categories 13: 1, 2, 3 , 4, 5, 6, 7

the average value of shud is 3. This is one of the possibilities. I need a number of features with such screens.

can someone help me with this, I guess this is a matter of some probability distributions.

+4
source share
1 answer

As an understanding of the Haskell list: (with only 3 parameters, but you get the point)

list input = [[a, b, c] | a <- [0..7], b <- [0..7], c <- [0..7], avg ([a, b, c]) == input]

then you select any random list from this list of lists

0
source

Source: https://habr.com/ru/post/1401310/


All Articles