# Algorithm-based game project to introduce quantum computing

I am currently working on a quantum computing subject for my coding school, and I had some questions for you. My objective would be to introduce students to quantum computing with an algorithmic project. I had two games ideas for it, one of them being harder to implement than the other one.

The first (the hardest), would be to provide each of the two players a quantum byte, randomly initialized: to do that, we would apply a Hadamard gate to each qubit in the byte, measure it, use the result of the measurement as the initial state for the byte, and then apply a Hadamard gate to each of the qubits again. This way, the player really has no way to know what lies within the byte. Once the bytes are initialized, each player is given a model of 7 bits he has to reproduce over measurement. For instance, if you are given the string 01110110, you would have to obtain either 01110110 or 11110110 upon measurement, the first qubit being used as a register, allowing the players to apply multi-qubit gates to the byte without alienating the rest of their QuBits. The first player who measures his byte and obtains what he or she was asked to obtain wins. This way students are introduced to quantum state preparation, and might even produce a strToQuBit type of function.

The second idea would be similar, but instead of a model of byte they would have to reproduce, the game would be played by two players, one would have to fill their byte with 1s, the other with 0s, in other words, the string they would have to obtain upon measurement would always be either (00000000 or 10000000), or (11111111 or 01111111). The byte would of course still be randomly initialized before players can work with it.

Which idea do you think is the best, and is such a project even doable?

EDIT: I have omitted an important precision: players cannot change the states of the qubits once they have measured it, and all QuBits will be measured at once. Once the whole byte has been measured, either the result corresponds to the model byte and the player wins, or it does not and then a new model byte is assigned to the player who failed! ;)

Does this make it more complex?

• It looks like your initial state is $H | i_0 \rangle \otimes H | i_1 \rangle \cdots$ unentangled (where $i_0 i_1 \cdots$ is the bit string). Did I parse that as intended? Because then you could separate the problem completely so it seems you should want something entangled instead. – AHusain Oct 16 '18 at 14:11
• I guess a completely entangled qByte could be interesting ! But I believe the projet is hard enough if we consider that all qubits will have to be measured together at once, and that the players cannot apply gates to the measured qubits ! – F. Sabatié Oct 17 '18 at 18:45
• With respect, I think that your revised problem isn't really very interesting. How is it different from rolling dice? – Niel de Beaudrap Oct 17 '18 at 19:35
• Thanks Niel ! I now understand why it is stupid :D AHusain's answer helped me understand why ! – F. Sabatié Oct 17 '18 at 20:49

This is definitely doable, but the tasks seem quite simple and they only introduce single-qubit measurement and the X gate, while quantum state preparation usually involves some superposition and entanglement generation. One can get rid of the input superposition by measuring each qubit and then use a bunch of X gates to set each qubit to the right state, you don't even need the scratch qubit for two-qubit gates.

I am biased in my recommendation, but I would suggest taking a look at the Quantum Katas project. I created it to help people learn quantum computing; it has some nice tasks of varying complexity and (most importantly) test harnesses that verify that the task solutions are correct. The Superposition kata in particular introduces state preparation. We have had a lot of success using the katas to teach people unfamiliar with quantum computing.

• Wow it’s a lot of useful resources thank you very much I sure will find inspiriation in your work ! I added a precision regarding my post, I believe it makes the task harder ;) – F. Sabatié Oct 17 '18 at 18:40

They certainly seem doable. I'd suggest the first one, as it is a little more complex. For added complexity you could also include constraints on the allowed gates, such as not allowing X or Y on certain qubits, but instead supplying CNOTs (so a $$|1\rangle$$ can be copied from other qubits) or partial rotations around the X and Y axis, such that the X or Y can be built up from multiple applications.

• I realise my proposition was flawed, but what you propose is really interesting James ! Thank you, I will look into that also ! – F. Sabatié Oct 17 '18 at 20:44

Consider the task on one qubit. You are given a state that is either $$H|0\rangle$$ or $$H|1\rangle$$ and your task before the measurement is to get it to be either more probably $$|0\rangle$$ or $$|1\rangle$$ as instructed. Say you were instructed to get 0, then you are trying for a unitary that takes both $$H \mid 0 \rangle$$ and $$H | 1 \rangle$$ to states close to $$|1\rangle$$. Say you do $$H$$ then you are good on half the initial states but not on the other half. Same if you do $$XH$$. The probabilities are $$\mid\langle 0 | U H | i \rangle \mid^2$$ where i indicates the starting and $$U$$ is what you do with it. But

$$\mid\langle 0 | U H | 0 \rangle \mid^2 + \mid\langle 0 | U H | 1 \rangle \mid^2 =\\ \mid\langle 0 | H U^\dagger | 0 \rangle \mid^2 + \mid\langle 1 | H U^\dagger | 0 \rangle \mid^2 = 1$$

so as you make the probability to get $$0$$ when you start in $$H|0\rangle$$ larger, you worsen the other case. Similarly if you were asked to get $$1$$.

Let's say $$p$$ is the probability that if it started in $$H|0\rangle$$ you got it into the desired result. There is $$1-p$$ that if it started in $$H|1\rangle$$ you got it into the desired result. Combine those $$\frac{1}{2}p + \frac{1}{2}(1-p) = \frac{1}{2}$$. No matter what you do, you can't escape the randomness of the initial state. If you knew something more about it then you could win, but right now you don't.

If you were allowed to do processing after the measurement, then do what Mariia suggested. But as stated it's a coin flip.

If the state was entangled then you could use some information that way, but right now the problem is broken up into each qubit.

• Mhmmm thanks ! I see what the problem is, allowing the player to measure the "register" QuBit at any moment but not the others would fix this right ? – F. Sabatié Oct 17 '18 at 20:34
• Also would you mind developing about the entangled state ? It seems like a good idea to give some information to the players without allowing them to make some measurement of the register QuBit ! – F. Sabatié Oct 17 '18 at 20:47