Voici comment on peut programmer cet algorithme en Python :
def face(n):
a = [1, 2, 3, 4, 5, n - 15]
while True:
if a[5] > a[4] and a[5] < 11:
print(a)
i = 4
while i > -1 and a[i] + 1 >= a[i+1]:
i -= 1
if i < 0:
return
a[i] += 1
while i < 4:
i += 1
a[i] = a[i - 1] + 1
s = 0
for i in range(5):
s += a[i]
a[5] = n - s
On peut alors compter le nombre de faces différentes possibles pour les sommes allant de 21 à 45.
Somme sur un face |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
---|
Nombre de faces |
1 |
1 |
2 |
3 |
5 |
6 |
9 |
10 |
13 |
14 |
16 |
16 |
18 |
16 |
16 |
14 |
13 |
10 |
9 |
6 |
5 |
3 |
2 |
1 |
1 |
---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|