Exercise

Three known values

Now, we will simulate the probability of correctly guessing when the passcode consists of three distinct digits where one of the values is repeated.

Here, suppose that the smudge marks are at the values of 2, 4, and 7. One of these values will be repeated in the passcode, but we do not know which one, nor where the repeated value is within the passcode.

Instructions

100 XP
  • Store the three known values into the variable called unique_values.
  • Create an object containing four total values, by choosing one of the unique values at random to be the repeated value and combining it with unique_values, and store it as all_values.
  • Make the guess by choosing at random from the object containing the four values.