I.7 Universal gate sets. Codercise 1.7.2

After a bit of struggle I got this exercise accepted with three gates:
qml.RZ(np.pi/2,wires=0)
qml.RX(-np.pi/2,wires=0)
qml.RZ(np.pi/4,wires=0)
I have two questions:
(a) the first gate is doing nothing ( initially I did not include it), but then exercise was autograded as incorrect.
(b) the codebook explanation below the exercise states “It is possible to complete the above exercise using only four gates!” Meanwhile 3 gates were accepted as correct (and 2 seem enough to me and also according to Quirk: Quantum Circuit Simulator)

Hey @Guntis_Barzdins! Welcome to the forum :rocket:

Indeed, your 3-gate answer is correct. I will update the codebook!

(a) the first gate is doing nothing ( initially I did not include it), but then exercise was autograded as incorrect.

Are you talking about removing the qml.RZ(np.pi/2,wires=0) operator? If so, I’m not sure about that. Consider the following:

@qml.qnode(dev)
def convert_to_rz_rx_1():
    qml.RZ(np.pi/2,wires=0)
    qml.RX(-np.pi/2,wires=0)
    qml.RZ(np.pi/4,wires=0)

    return qml.state()

@qml.qnode(dev)
def convert_to_rz_rx_2():
    #qml.RZ(np.pi/2,wires=0)
    qml.RX(-np.pi/2,wires=0)
    qml.RZ(np.pi/4,wires=0)

    return qml.state()

print(convert_to_rz_rx_1())
'''
[0.27059805-0.65328148j 0.27059805+0.65328148j]
'''
print(convert_to_rz_rx_2())
'''
[ 0.65328148-0.27059805j -0.27059805+0.65328148j]

'''

Also,

op = qml.RZ(np.pi/2,wires=0)
print(op.matrix())
'''
[[0.70710678-0.70710678j 0.        +0.j        ]
 [0.        +0.j         0.70710678+0.70710678j]]
'''

Thank you for the feedback!