538 (fivethirtyeight.com) is a personal favorite website of mine that uses data and statistical analysis to tell compelling stories about sports, politics, and science. Another reason I enjoy 538 is because every Friday they post the Riddler, a column containing two riddles. These riddles vary in content but usually involve some sort of probability, statistics, or other number crunching. On November 12, 2021 the Riddler Express post stated the following:
I have three dice (d4, d6, d8) on my desk that I fiddle with while working, much to the chagrin of my co-workers. For the uninitiated, the d4 is a tetrahedron that is equally likely to land on any of its four faces (numbered 1 through 4), the d6 is a cube that is equally likely to land on any of its six faces (numbered 1 through 6), and the d8 is an octahedron that is equally likely to land on any of its eight faces (numbered 1 through 8).
I like to play a game in which I roll all three dice in “numerical” order: d4, then d6 and then d8. I win this game when the three rolls form a strictly increasing sequence (such as 2-4-7, but not 2-4-4). What is my probability of winning?
Extra credit: Instead of three dice, I now have six dice: d4, d6, d8, d10, d12 and d20. If I roll all six dice in “numerical” order, what is the probability I’ll get a strictly increasing sequence?
Method
To solve this riddle, I created a script in MATLAB. I used nested for-loops to simulate every possible outcome of the d4, d6, then d8 dice rolls. An if-statement with the proper conditions of “winning”, a strictly increasing sequence, checked each combination and totalled the number of wins. The wins are then compared to the total number of outcomes which is equal to the products of the die faces. Here there are 192 total outcomes (4*6*8).
An identical solution was performed for the extra credit which used the same premise but used a d4, d6, d8, d10, d12, and d20 die. See the full code below.
%Riddler 11/12
%Pierce Heintzelman
clear
clc
%%
count = 0;
win = 0;
for i = 1:4
for j = 1:6
for k = 1:8
result = [i j k];
if result(1) < result(2) && result(2) < result (3)
win = win+1;
end
count = count + 1;
end
end
end
prob = win/count;
display(prob)
%% EC
count = 0;
win = 0;
for i = 1:4
for j = 1:6
for k = 1:8
for x = 1:10
for y = 1:12
for z = 1:20
result = [i j k x y z];
if i < j && j < k && k < x && x < y && y < z
win = win+1;
end
count = count + 1;
end
end
end
end
end
end
prob = win/count;
display(prob)
Results
For the first situation with a d4, d6, and d8 die, you have a 0.25 probability of winning. Not too shabby! However, when you increase the game to the six die of d4, d6, d8, d10, d12, and d20, your probability of winning plummets massively to 0.0118. In this version there are exactly 460,800 possible outcomes! The odds quickly work against you. For a pdf version of my code using an interactive MATLAB script along with displayed results, see below.