Please teach the construction law of Orcle Uf in Grover's algorithm

The framework of Grover’s algorithm is shown in Figure from Qiskit.

But I didn’t understand the tutorial’s construction rules for U_f. If there are four qubits, labeled 0001, 0010, 1001, and 1110, how to design U_f? If there are 5 bits, labeled 00101, 01010, 10101, and 11110, how to design U_f? Can you summarize in code how Uf imposes CZ gates?

@CatalinaAlbornoz

Hey @R-X!

Great question. I think you should check out our YouTube video for Grover’s algorithm: https://www.youtube.com/watch?v=EfUfwVnicP8

It should answer a lot of your questions!