4 min read

Can You Systematically Solve A Friday Crossword?

Table of Contents

Riddler Express

You’re playing a game of cornhole with your friends, and it’s your turn to toss the four bean bags. For every bean bag you toss onto your opponents’ board, you get 11 point. For every bag that goes through the hole on their board, you get 33 points. And for any bags that don’t land on the board or through the hole, you get 00 points.

Your opponents had a terrible round, missing the board with all their throws. Meanwhile, your team currently has 1818 points β€” just 33 points away from victory at 2121. You’re also playing with a special house rule: To win, you must score exactly 2121 points, without going over.

Based on your history, you know there are three kinds of throws you can make:

  • An aggressive throw, which has a 4040 percent chance of going in the hole, a 3030 percent chance of landing on the board and a 3030 percent chance of missing the board and hole.
  • A conservative throw, which has a 10 percent chance of going in the hole, an 8080 percent chance of landing on the board and a 1010 percent chance of missing the board and hole.
  • A wasted throw, which has a 100100 percent chance of missing the board and hole.

For each bean bag, you can choose any of these three throws. Your goal is to maximize your chances of scoring exactly 33 points with your four tosses. What is the probability that your team will finish the round with exactly 2121 points and declare victory?

Solution

Let us consider the general case of an NN-throw game, and let the state be the number of points. The optimal probability Pk(xk)P_k(x_k) at the start of the kthk^{th} throw as a function of the number of points xkx_k is given by the dynamic programming recursion

Pk(xk)=max⁑[ahPk+1(xk+3)+abPk+1(xk+1)+amPk+1(xk),chPk+1(xk+3)+cbPk+1(xk+1)+cmPk+1(xk),Pk+1(xk)]\begin{align*} P_k(x_k) = \max[&a_h P_{k+1}(x_k+3) + a_b P_{k+1}(x_k+1) + a_m P_{k+1}(x_k), \\\\ &c_h P_{k+1}(x_k+3) + c_b P_{k+1}(x_k+1) + c_m P_{k+1}(x_k),\\\\ &P_{k+1}(x_k)] \end{align*}

where ah,ab,ama_h,a_b,a_m and ch,cb,cmc_h,c_b,c_m are the probabilities of a throw landing in the hole, on the board and missing the board under aggressive and conservative throws.

The maximum above is taken over the three possible decisions:

  • Aggressive throw, which keeps the score at xkx_k with probability ama_m, changes it to xk+3x_k+3 with probability aha_h and xk+1x_k+1 with probability aba_b.

  • Conservative throw, which keeps the score at xkx_k with probability cmc_m, changes it to xk+3x_k+3 with probability chc_h and xk+1x_k+1 with probability cbc_b.

  • Wasted throw, which keeps the score at xkx_k with probability 11.

The required probability is obtained by calculating P1(0)P_1(0) given N=4N=4 and the following terminal conditions:

P4(0)=0.4P4(1)=0P4(2)=0.8P4(3)=1\begin{align*} P_4(0) &= 0.4 \\\\ P_4(1) &= 0 \\\\ P_4(2) &= 0.8 \\\\ P_4(3) &= 1 \end{align*}

From the code below, the probability that the team will finish the round with exactly 2121 points and declare victory is 85.48%\bf{85.48}\%.

Computation

N, max_pts = 4, 3
P = zeros(Float32, N, N*max_pts+1)
P[N,1], P[N,3], P[N,4] = 0.4, 0.8, 1
aβ‚•, aᡦ, aβ‚˜ = 0.4, 0.3, 0.3
cβ‚•, cᡦ, cβ‚˜ = 0.1, 0.8, 0.1
for k in N-1: -1 :1
    for x in 1:k*max_pts+1
        P[k,x] = max(aβ‚•*P[k+1,x+3]+aᡦ*P[k+1,x+1]+aβ‚˜*P[k+1,x],
                     cβ‚•*P[k+1,x+3]+cᡦ*P[k+1,x+1]+cβ‚˜*P[k+1,x],
                     P[k+1,x])
    end
end
print(P[1,1])