3 min read

Can You Hunt For The Mysterious Numbers?

Table of Contents

Riddler Express

You’re a contestant on the hit new game show, β€œYou Bet Your Fife.” On the show, a random real number (i.e., decimals are allowed) is chosen between 00 and 100100. Your job is to guess a value that is less than this randomly chosen number. Your reward for winning is a novelty fife that is valued precisely at your guess. For example, if the number is 7575 and you guess 55, you’d win a \5fife,butifyou’dguessed5 fife, but if you’d guessed 60,you’dwina, you’d win a \\60 fife. Meanwhile, a guess of 8080 would win you nothing. What number should you guess to maximize the average value of your fifing winnings?

Solution

Let X∼U[0,100]X\sim\mathcal{U}[0,100] be the random variable representing the random real number that is chosen. Let YY be the random variable representing the fifing winnings.

We have

Y={g,g<X0,gβ‰₯X\begin{equation*} Y = \begin{cases} g, & g < X \\ 0, & g \geq X \end{cases} \end{equation*}

where gg is the number you should guess.

Also, P[Y=g]=P[X>g]=100βˆ’g100\mathbb{P}[Y = g] = \mathbb{P}[X > g] = \frac{100-g}{100}.

Therefore, E[Y]=gβ‹…P[Y=g]=g(100βˆ’g)100\mathbb{E}[Y] = g \cdot \mathbb{P}[Y = g] = \frac{g(100-g)}{100}.

The epectation takes the maximum value when g=100βˆ’g=50g = 100 - g = 50 and maximum value of the expectation is 2525.

Riddler Classic

There are eight three-digit numbers β€” each belongs in a row of the table below, with one digit per cell. The products of the three digits of each number are shown in the rightmost column. Meanwhile, the products of the digits in the hundreds, tens, and ones places, respectively, are shown in the bottom row.

Table for eight three-digit numbers. The products of the three digits in each number are, respectively, 294294, 216216, 135135, 9898, 112112, 8484, 245245 and 4040. The product of the hundreds digits is 8,890,5608,890,560. The product of the tens digit is 156,800156,800. The product of the ones digit is 55,566455,5664.

Can you find all eight three-digit numbers and complete the table?

Computational Solution

from z3 import *

class MysteriousNumbersSolver:
    def __init__(self):
        self.X = [[Int("self.X_%s_%s" % (i, j)) for j in range(3)]
                      for i in range(8)]
        self.s = Solver()
        self.s.add([And(0 <= self.X[i][j], self.X[i][j]<= 9) for i in range(8) for j in range(1,3)])
        self.s.add([And(0 <= self.X[i][0], self.X[i][0]<= 9) for i in range(8)])

    def set_constraints(self):   
        self.s.add(self.X[0][0]*self.X[0][1]*self.X[0][2]==294)
        self.s.add(self.X[1][0]*self.X[1][1]*self.X[1][2]==216)
        self.s.add(self.X[2][0]*self.X[2][1]*self.X[2][2]==135)
        self.s.add(self.X[3][0]*self.X[3][1]*self.X[3][2]==98)
        self.s.add(self.X[4][0]*self.X[4][1]*self.X[4][2]==112)
        self.s.add(self.X[5][0]*self.X[5][1]*self.X[5][2]==84)
        self.s.add(self.X[6][0]*self.X[6][1]*self.X[6][2]==245)
        self.s.add(self.X[7][0]*self.X[7][1]*self.X[7][2]==40)
        self.s.add(self.X[0][0]*self.X[1][0]*self.X[2][0]*self.X[3][0]*self.X[4][0]*self.X[5][0]*self.X[6][0]*self.X[7][0]==8890560)
        self.s.add(self.X[0][1]*self.X[1][1]*self.X[2][1]*self.X[3][1]*self.X[4][1]*self.X[5][1]*self.X[6][1]*self.X[7][1]==156800)
        self.s.add(self.X[0][2]*self.X[1][2]*self.X[2][2]*self.X[3][2]*self.X[4][2]*self.X[5][2]*self.X[6][2]*self.X[7][2]==55566)

    def output_solution(self):
        m = self.s.model()
        for i in range(8):
            print(" ".join([str(m.evaluate(self.X[i][j])) for j in range(3)]))

    def solve(self):
        self.set_constraints()
        if self.s.check() == sat:
            self.output_solution()
        else:
            print(self.s)
            print("Failed to solve.")

s = MysteriousNumbersSolver()
s.solve()

Here is the solution

7 7 6
9 8 3
9 5 3
7 2 7 
8 2 7 
7 4 3 
5 7 7 
8 5 1