Challenge - Game of Doors¶
You’re preparing for a game show where you play the following game.
You’re faced with four doors
Behind one door is cash money 🤑 Behind the other three doors is steaming pile of broccoli 🥦
If you pick the door with money, you get the option to play again at the risk of losing the money you’ve collected thus far. If you keep winning, you can play a maximum of three rounds before the game show host kicks you off his show.
You have some strategy ideas you’d like to evaluate before you go on the show. You hire an unpaid intern to scour through historic recordings of the show and log data on where prizes were located and the value of each prize.
Your intern gets back to you with the following matrices:
prize_doors
: Here, element (i,j) identifies the door hiding the prize in the ith game of round j
prizes
: Here (i, j) gives the prize amount in the ith game of round j
Build a 5x3x4 matrix where (i,j,k) represents the prize behind door k of round j of game i.
import numpy as np
prize_doors = np.array([
[1, 0, 2],
[0, 0, 1],
[3, 3, 1],
[1, 2, 0],
[2, 1, 1]
])
prizes = np.array([
[100, 150, 500],
[200, 300, 250],
[150, 100, 325],
[425, 200, 100],
[200, 250, 300]
])
result = np.zeros((5,3,4))
result[np.arange(5)[:, None], np.arange(3)[None, :], prize_doors] = prizes
result
array([[[ 0., 100., 0., 0.], [150., 0., 0., 0.], [ 0., 0., 500., 0.]], [[200., 0., 0., 0.], [300., 0., 0., 0.], [ 0., 250., 0., 0.]], [[ 0., 0., 0., 150.], [ 0., 0., 0., 100.], [ 0., 325., 0., 0.]], [[ 0., 425., 0., 0.], [ 0., 0., 200., 0.], [100., 0., 0., 0.]], [[ 0., 0., 200., 0.], [ 0., 250., 0., 0.], [ 0., 300., 0., 0.]]])