SHOW:
|
|
- or go back to the newest paste.
1 | - | from itertools import product, groupby |
1 | + | Points 6 prob = 1 / 46656 |
2 | - | |
2 | + | Points 7 prob = 6 / 46656 |
3 | - | def dice_probability(n): |
3 | + | Points 8 prob = 21 / 46656 |
4 | - | if n <= 0: |
4 | + | Points 9 prob = 56 / 46656 |
5 | - | print(n, "n must be a positive integer.") |
5 | + | Points 10 prob = 126 / 46656 |
6 | - | return [] |
6 | + | Points 11 prob = 252 / 46656 |
7 | - | points = [ sum(p) for p in product(range(1,7), repeat = n) ] |
7 | + | Points 12 prob = 456 / 46656 |
8 | - | prob = [ ( k, len(list(g)) ) for k, g in groupby(sorted(points)) ] |
8 | + | Points 13 prob = 756 / 46656 |
9 | - | return prob |
9 | + | Points 14 prob = 1161 / 46656 |
10 | - | |
10 | + | Points 15 prob = 1666 / 46656 |
11 | - | N = 6 |
11 | + | Points 16 prob = 2247 / 46656 |
12 | - | dice_p = dice_probability(N) |
12 | + | Points 17 prob = 2856 / 46656 |
13 | - | total = 6**N |
13 | + | Points 18 prob = 3431 / 46656 |
14 | - | for t in dice_p: |
14 | + | Points 19 prob = 3906 / 46656 |
15 | - | print("Points %2d prob = %5d / %5d" % (t[0], t[1], total)) |
15 | + | Points 20 prob = 4221 / 46656 |
16 | Points 21 prob = 4332 / 46656 | |
17 | Points 22 prob = 4221 / 46656 | |
18 | Points 23 prob = 3906 / 46656 | |
19 | Points 24 prob = 3431 / 46656 | |
20 | Points 25 prob = 2856 / 46656 | |
21 | Points 26 prob = 2247 / 46656 | |
22 | Points 27 prob = 1666 / 46656 | |
23 | Points 28 prob = 1161 / 46656 | |
24 | Points 29 prob = 756 / 46656 | |
25 | Points 30 prob = 456 / 46656 | |
26 | Points 31 prob = 252 / 46656 | |
27 | Points 32 prob = 126 / 46656 | |
28 | Points 33 prob = 56 / 46656 | |
29 | Points 34 prob = 21 / 46656 | |
30 | Points 35 prob = 6 / 46656 | |
31 | Points 36 prob = 1 / 46656 |