#Creates a list of all 1,296 dice rolls for 4 dice.
#Creates a list of the corresponding 6 sums for each of the 1,296 rolls.
all_dice = []
all_sums = []
for d0 in range(1, 7) :
for d1 in range(1, 7) :
for d2 in range(1, 7) :
for d3 in range(1, 7) :
all_dice.append((d0, d1, d2, d3))
all_sums.append((d0+d1,
d0+d2,
d0+d3,
d1+d2,
d1+d3,
d2+d3))
#Takes a number between 2 - 12 and removes any of the sums that contains that number.
#Returns the modified list of sums.
def removeSums(n, list_of_sums):
new_sums = []
for sums in list_of_sums:
if n not in sums:
new_sums.append(sums)
return(new_sums)
#For each of the sums of two dice, 2 - 12,
#how many of the 1296 dice rolls does it exist in?
#This loop returns a dictionary of the sum and the count.
sum_count = dict()
for s in range(2, 13):
sum_count[s] = 1296 - len(removeSums(s, all_sums))
sum_count
#For each of the sums of two dice, 2 - 12,
#how many times does it exist in the 1296 dice rolls?
#This loop returns a dictionary of the sum and the count.
all_sums_flat = [s for sums in all_sums for s in sums]
all_sums_count = {}
for s in all_sums_flat:
if s not in all_sums_count.keys():
all_sums_count[s] = 1
else:
all_sums_count[s] += 1
all_sums_count
#For each of the 330 combinations of 4 dice sums,
#this loop returns a dictionary of the quadruple and the number of winning possibilities.
remaining = dict()
for s1 in range(2, 10):
for s2 in range(s1+1, 11):
for s3 in range(s2+1, 12):
for s4 in range(s3+1, 13):
remaining[(s1, s2, s3, s4)] = 1296 - len(removeSums(s1, removeSums(s2, removeSums(s3, removeSums(s4, all_sums)))))
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
#Plot.
sns.set()
fig = plt.figure(figsize = (14, 8))
ax = fig.add_subplot()
#Histogram.
#Change first and last color.
N, bins, patches = ax.hist(x = remaining.values(),
#Number of bins.
bins = 15*np.arange(35)+774 ,
align = "mid")
for i in range(0,1):
patches[i].set_facecolor('#481567')
for i in range(1, len(patches)-2):
patches[i].set_facecolor('#2D708E')
for i in range(len(patches)-2, len(patches)):
patches[i].set_facecolor('#3CBB75')
#Title.
ax.set_title("Distribution of 330 Sums Choice Possibilities and Dice Rolls Won", fontsize = 24)
#Axes.
ax.set_xlabel("Dice Rolls Won", fontsize = 18)
ax.set_ylabel("Number of Sum Choices", fontsize = 18)
ax.tick_params(axis = 'both', labelsize = 16)
#Min text.
ax.annotate('Minimum Winnings: 774',
xy = (750, 4),
xytext = (750, 4),
fontsize = 18,
fontweight = 'bold',
color = '#481567');
ax.annotate('Sums: 2, 3, 11, 12',
xy = (770, 2.5),
xytext = (770, 2.5),
fontsize = 18,
fontweight = 'bold',
color = '#481567');
#Max text.
ax.annotate('Maximum Winnings: 1264',
xy = (1150, 4),
xytext = (1150, 4),
fontsize = 18,
fontweight = 'bold',
color = '#3CBB75');
ax.annotate('Sums: 4, 6, 8, 10',
xy = (1175, 2.5),
xytext = (1175, 2.5),
fontsize = 18,
fontweight = 'bold',
color = '#3CBB75');
fig.savefig("2022.03.11 Classic1.png")
for key in remaining.keys():
if remaining[key] > 1237:
print(key, remaining[key])
(2, 6, 8, 10) 1246 (4, 6, 7, 9) 1238 (4, 6, 8, 10) 1264 (4, 6, 8, 12) 1246 (5, 7, 8, 10) 1238