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 and . 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 and you guess , youβd win a \6060 fife. Meanwhile, a guess of would win you nothing. What number should you guess to maximize the average value of your fifing winnings?
Solution
Let be the random variable representing the random real number that is chosen. Let be the random variable representing the fifing winnings.
We have
where is the number you should guess.
Also, .
Therefore, .
The epectation takes the maximum value when and maximum value of the expectation is .
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, , , , , , , and . The product of the hundreds digits is . The product of the tens digit is . The product of the ones digit is .
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