Oooh, this was fun! It took a lot of experimentation, but I solved it with X -> Z -> H -> Z!
The hadamard gate puts it in superposition right? What kind of problem does this little program-challenge represent?
Awesome, I'm so glad you had fun. I'm fairly certain 4 gates is the best you can do!
Yes exactly, the hadamard gate puts the qubit in superposition
(|↗ > is a superposition of |→> and |↑>).
On one hand this puzzle is a bit of a contrived example that I came up with to challenge people :| , but on the other hand (and after thinking about it some more) it does represent a real problem that quantum algorithm researchers face: figuring out how to create states using as few "standard" operations as possible. Real quantum computers have a limited set of "standard" gates (The X, Z, and H gates are all standard operations). The |↙> state may be especially interesting to create—in as few gates as possible—because |↙> = -|↗>, it's the negative version of the superposition |↗>!
So all that to say, you now know how to prepare a useful qubit state using as few quantum operations as possible (using the same operations some real quantum computers have). Every operation counts in a quantum computer because current quantum computers get "noisy" after just a handful of operations.
Thanks for your comment @Ramona!