5 min read

Are You Clever Enough?

Table of Contents

Riddler Express

You are very clever when it comes to solving Riddler Express puzzles. You are so clever, in fact, that you are in the top 1010 percent of solvers in Riddler Nation (which, as you know, has a very large population). You don’t know where in the top 1010 percent you are β€” in fact, you realize that you are equally likely to be anywhere in the topmost decile. Also, no two people in Riddler Nation are equally clever.

One Friday morning, you walk into a room with ninenine members randomly selected from Riddler Nation. What is the probability that you are the cleverest solver in the room?

Solution

Without loss of generality we can assume that the normalized IQ of the population follows the Uniform distribution U[0,1]\mathcal{U}[0,1].Let X1,X2,…,XnX_1, X_2, \dots, X_n be the random variables representing the IQs of the other individuals in the room apart from you where Xi∼U[0,1]X_i \sim \mathcal{U}[0,1] for i∈{1,…,n}i \in \{1,\dots,n\}. Let Y∼U[a,b]Y \sim \mathcal{U}[a,b] be the random variable representing your IQ where 0≀a<b≀10 \leq a < b \leq 1. We need the probability P[X(n)<Y]\mathbb{P}[ X_{(n)} < Y ] where X(n)=max⁑(X1,…,Xn)X_{(n)}= \max(X_1,\dots, X_n). From Order Statistics of the Uniform distribution, we know that P[X(n)<y]=yn\mathbb{P}[X_{(n)} < y ] = y^n. Therefore the required probability is given by

P[X(n)<Y]=∫abyn1bβˆ’ady=bn+1βˆ’an+1(n+1)(bβˆ’a)\begin{aligned} \mathbb{P}[ X_{(n)} < Y ] &= \int_{a}^b y^n \frac{1}{b-a} dy \\\\ &= \frac{b^{n+1}- a^{n+1}}{(n+1)(b-a)} \end{aligned}

When n=9,a=0.9n=9, a= 0.9 and b=1.0b=1.0 the required probability is 0.65132\textbf{0.65132}.

Computational Solution

From the simulation below, we can see that the required probability is indeed β‰ˆ0.651\approx \textbf{0.651}.

import numpy as np

def prob_you_cleverest(n, start_iq = 0.9, end_iq = 1.0, runs = 5000000):
    others_iqs = np.random.rand(runs, n)
    your_iqs = np.random.uniform(start_iq, end_iq, runs)
    return np.mean(np.where(np.max(others_iqs, axis=1) < your_iqs, [1], [0]))

print(prob_you_cleverest(9))

Riddler Classic

You have four standard dice, and your goal is simple: Maximize the sum of your rolls. So you roll all four dice at once, hoping to achieve a high score.

But wait, there’s more! If you’re not happy with your roll, you can choose to reroll zero, one, two or three of the dice. In other words, you must β€œfreeze” one or more dice and set them aside, never to be rerolled.

You repeat this process with the remaining dice β€” you roll them all and then freeze at least one. You repeat this process until all the dice are frozen.

If you play strategically, what score can you expect to achieve on average?

Extra credit: Instead of four dice, what if you start with five dice? What if you start with six dice? What if you start with NN dice?

Computational Solution

Let the number of dice be NN, a roll can be represented as an NN-tuple (d1,d2,…,dN)(d_1, d_2, \dots, d_N) where di∈{1,…,6}d_i \in \{1,\dots, 6\} for i∈{1,…,6}i \in \{1,\dots, 6\}. There are a total of 6N6^N possible rolls. Let MES(roll)MES(roll) be the function which gives you the maximum expected score that can be achieved starting from a given roll by choosing to reroll zero, one, two or Nβˆ’1N-1 dice. The expected maximum score is then given by

EMS(N)=βˆ‘16Nβ‹…MES(roll)EMS(N) = \sum \frac{1}{6^N} \cdot MES(roll)

where roll∈(d1,d2,…,dN)∣di∈1,…,6,i∈1,…,Nroll \in \\{(d_1,d_2,\dots, d_N) \lvert d_i \in \\{1,\dots,6\\}, i \in \\{1, \dots, N\\} \\}.

For a given roll (d1,d2,…,dN)(d_1, d_2, \dots, d_N), let (ds(1),ds(2),…,ds(N))(d_{s(1)}, d_{s(2)}, \dots, d_{s(N)}) be the corresponding tuple sorted in descending\textbf{descending} order.

The maximimum expected score that can be obtained by following the optimal strategy starting from a given initial roll can be calculated as follows:

  1. We first freeze the maximum value of a roll ds(1)d_{s(1)}.

  2. We then calculate the maximum expected score that can result by rerolling 0,…,Nβˆ’10, \dots, N-1 remaining dice. If we are rolling jj dice, the maximum expected score is the sum of the expected maximum score for those dice EMS(j)EMS(j) and the top Nβˆ’1βˆ’jN-1-j of the remaining values of the roll after removing the maximum value which was already frozen.

This leads to the following definition of the function MESMES:

MES((d1,d2,…,dN))=ds(1)+max⁑{EMS(j)+βˆ‘i=2Nβˆ’jds(j)∣j∈{0,…,Nβˆ’1}}=max⁑{EMS(j)+βˆ‘i=1Nβˆ’jds(j)∣j∈{0,…,Nβˆ’1}}\begin{aligned} MES((d_1, d_2, \dots, d_N)) = d_{s(1)} + \\ \max \left \{EMS(j) + \sum_{i=2}^{N-j}d_{s(j)} \bigl \vert j \in \{0, \dots, N-1\} \right\} \\ = \max \left \{EMS(j) + \sum_{i=1}^{N-j}d_{s(j)} \bigl \vert j \in \{0, \dots, N-1\} \right\} \end{aligned}

where jj stands for the number of dice that are rerolled.

From the above it is clear that EMS(N)EMS(N) is ultimately defined in terms of EMS(0)=0,EMS(1),…,EMS(Nβˆ’1)EMS(0)=0, EMS(1), \dots, EMS(N-1) and it can be calculated iteratively.

Using the code below, we see that the maximum score that can be achieved on average is 989065/52488=18.843\textbf{989065/52488=18.843}.

from itertools import product
from fractions import Fraction

def MESs(num_dice):
    exp_max_scores = {}
    exp_max_scores[0] = 0
    for n in range(1, num_dice+1):
        total_mes = 0
        for roll in product(range(1, 6 + 1), repeat = n):
            sorted_roll = sorted(list(roll), reverse=True)
            total_mes += max(sum(sorted_roll[:n-j]) + exp_max_scores[j] for j in range(n))
        exp_max_scores[n]=Fraction(total_mes, 6**n)
    return exp_max_scores

mess = MESs(5)
for i in range(1,5):
    print(f"The average max score for {i} dice is {mess[i]}")

The average max score for 1 dice is 7/2
The average max score for 2 dice is 593/72
The average max score for 3 dice is 13049/972
The average max score for 4 dice is 989065/52488