In the quantum pair-testing scheme, for each pair labelled by
where the top line stands for
Implement this circuit and return the
probabilities on the last qubit. The function oracle_matrix
is
defined for you. You can expand the box below to see the docstring
and implementation.
def oracle_matrix(combo): """Return the oracle matrix for a secret combination. Args: combo (list[int]): A list of bits representing a secret combination. Returns: array[float]: The matrix representation of the oracle. """ index = np.ravel_multi_index(combo, [2]*len(combo)) # Index of solution my_array = np.identity(2**len(combo)) # Create the identity matrix my_array[index, index] = -1 return my_array
To interact with codercises, please switch to a larger screen size.
Learning Objectives: