Quick Reference
Welcome to the second part of the Quantum Summer Lab 2025.
Using this web application, you can learn and practice your Q# quantum programming skills and your quantum logic knowledge by solving multiple challenges ranging from easy to more difficult.
This page provides you with a quick reference to some of the basics regarding quantum logic and Q# syntax.
Use the table of contents on the right hand side to navigate the different topics.
About this platform
This platform makes it easier for you to learn and challenge yourself by experimenting with quantum logic and Q# in an interactive way.
The web application that you are using to navigate this platform contains the following features:
Home page
The home page is a welcome page including the logo's of the organizers of this Quantum Summer Lab 2025 with links to their website.
It also contains a visual overview of all the challenges, categorized on difficulty, colored in green or red depending on whether you have solved it.
Quick reference
The quick reference page is the page you are viewing right now. It contains information about this Quantum Summer Lab challenge platform, quantum logic, gates and circuits, and the Q# programming language.
Challenge
The challenge page contains the title, description and solution template for each challenge.
Please read the full challenge description before attempting to solve the challenge as it contains all of the requirements to successfully solve the challenge.
The solution template using Q# syntax always contains the exact signature of the operation you need to submit as a solution to the challenge. Your task is always to implement the operation by writing the necessary code without changing the signature of the operation.
Each challenge page contains a 'Submit your solution' box with a text field that takes your solution and buttons to submit that solution or clear the text field.
Submitting your proposed solution starts the evaluation on our Quantum Summer Lab challenge platform servers and if all our internal tests are successful, your proposed solution will be accepted and the challenge will be closed for you. If there are issues with your proposed solution, you will get some feedback, based on the challenge, and can try again as many times as you want.
Below the 'Submit your solution' box is a list of your attempts to solve the challenge. We will keep all of your attempts, including the proposed Q# code and the feedback you received for future reference.
From the challenge page, you are able to summon the Quantum Summer Lab Copilot chat and ask it for help with the current challenge.
Leaderboard
The leaderboard page contains a list of all participating teams and their position (1st, 2nd, 3rd, ...) based on score and solving speed.
Points are calculated from a base score of 100 points, adding 100, 200, 300 or 400 points for each successfully solved challenge (based on its difficulty level), subtracting 1 point for each failed attempt to solve a challenge.
The Quantum Summer Lab 2025 is not a competition, but this leaderboard just gives you that little incentive to try your best solving challenges 😀
Copilot
The copilot page contains a custom LLM-based copilot chat that is grounded with information about the Quantum Summer Lab and the challenges on this challenge platform.
You can use it to ask for assistance using Q#, quantum logic and with whatever challenge you need help with.
The Quantum Summer Lab copilot will keep the chat history for your team so it should be aware of the context of your conversation.
You can also summon the Quantum Summer Lab Copilot from the challenge page itself by clicking the dedicated button on the bottom-right.
The Quantum Summer Lab copilot can help you with the following things:
Guidance on quantum logic, gates and circuits.
Guidance on the Q# programming language.
Information and guidance on the current challenge you are working on. Use it on the challenge page, or tell it the challenge code (A1..D3) you are working on.
Information and guidance on your last attempt for a specific challenge.
Information about the leaderboard.
Prerequisites
You will have a much richer experience writing Q# code by using the Visual Studio Code IDE. You can start here and test your solutions locally before copying them to this platform and submit as your solution.
Download and install Visual Studio Code and its Q# extension from the following website(s) to get started with Microsoft Q#.
Visual Studio Code (code editor with support for Q#)Azure Quantum Development Kit (QDK) extension
Use the following link to get a quick introduction to the Microsoft Q# programming language.
https://learn.microsoft.com/en-us/azure/quantum/qsharp-overviewUse the following link to get a quickstart and create your first Q# program.
https://learn.microsoft.com/en-us/azure/quantum/qsharp-quickstartUse the following link to get an overview on the Q# standard library.
https://learn.microsoft.com/en-us/qsharp/api/qsharp-lang/Quantum logic
This part of the quick reference will give you some information on the most important quantum operations.
H-gate
A very fundamental but powerful quantum gate is the Hadamard gate, based on the Hadamard transform and named after the French mathematician Jacques Hadamard.
The Hadamard gate allows you to manipulate the state vector of a single qubit and put it in a superposition of the |0⟩ and |1⟩ states. In a graphical visualization for a circuit, which is shown in the next figure, the Hadamard gate is often represented by a box with the capital letter H inside. The figure also shows a wire, representing the lifetime of a qubit |q⟩ in an arbitrary state.
If you visualize the Hadamard transformation on the Bloch sphere, think about a rotation of the state vector around a diagonal axis in between the x and z axis. The figure illustrates this rotation of π radians or 180 degrees on the Bloch sphere.
X-gate
Another fundamental quantum gate is the X-gate, which is also sometimes called the bitflip gate. The X-gate allows you to flip the |0⟩ state to a |1⟩ state and vice versa. Because of this, it is very similar to the classical NOT gate.
In a circuit, the X-gate is often visualized as a box with the capital letter X inside. The next figure shows a circuit where a qubit |q⟩ has the X-gate applied to it.
If you visualize the X-gate on the Bloch sphere, you should think about a π radians or 180 degrees rotation around the x axis. The figure shows this rotation if you start with a |0⟩ state making you end up with the |1⟩ state.
Y-gate
Just like the X-gate, the Y-gate will rotate the state vector with an angle of π radians or 180 degrees, but this time, around the Y-axis.
Very similarly to the H- and X-gate, the Y-gate is visualized in a circuit as a box with the capital letter Y inside. The next figure shows the Y-gate applied to a qubit |q⟩.
You can visualize the Y-gate on the Bloch sphere by thinking about a π radians or 180 degrees rotation around the y axis. The figure shows this rotation if you start with a |0⟩ state making you end up with the |1⟩ state.
Z-gate
Finally, the third rotation-gate or Z-gate will rotate the state vector π radians or 180 degrees around the Z-axis.
Very similarly to the H-, X-, and Y-gate, the Z-gate is visualized in a circuit as a box with the capital letter Z inside. The next figure shows the Z-gate applied to a qubit |q⟩.
You can visualize the Z-gate on the Bloch sphere by thinking about a π radians or 180 degrees rotation around the z axis. The figure shows this rotation if you start with a superposition |+⟩ state making you end up with the superposition |-⟩ state.
Measurement
The measurement gate is a bit different when compared to the other gates. The measurement gate does not apply a unitary transformation to the state vector but is collapses the state to one of its basis states. Because of this, the measurement gate is not reversible because you lose complex state information and is therefore not an actual quantum gate. Measurement causes the quantum state to be observed and thus collapses the wave function. The quantum state will be projected to one of its basis states, |0⟩ or |1⟩.
The measurement gate bridges the gap between the quantum world and the classical Boolean world. You can use quantum state information to achieve logic that can otherwise not be achieved in the classical world, but you need to retrieve classical information in the end. A typical quantum algorithm will have its quantum state prepared by a classical computer, several quantum operations executed on that state by quantum hardware and finally some measurements performed to return a piece of classical information.
The next figure shows the graphical visualization in a quantum circuit. A measurement is represented by a box with a measurement device and the capital letter M.
CNOT-gate
The CNOT-gate is a very important quantum gate and is the base for the entanglement circuit which will be uncovered later in this section. The CNOT-gate is the controlled version of the X-gate, which means that it will apply the X-gate on one of two qubits, only if the other qubit is ONE. The next figure shows the visualization of a CNOT-gate, applied on two qubits. The CNOT-gate has a solid dot on the qubit that is the control qubit and a circle with a plus inside on the qubit where the X-gate is applied to. The solid dot and the circle are connected with a line to make it clear that both shapes belong to the same gate.
Entanglement
The next figure shows a circuit with two wires, representing two qubits that have been initialized to the |0⟩ state. The first qubit is put in superposition with the help of the Hadamard gate. Next, the CNOT gate is applied with the first qubit, which is in superposition, as the control qubit and the second qubit as the target qubit. The CNOT gate will apply the X gate to the target qubit if the control qubit is in the |1⟩ state. Because the control qubit is in superposition, the two qubits participating in the CNOT gate are entangled. Measuring the two qubits at the end of this circuit will have them collapse to |00⟩ or |11⟩ with a 50% chance each.
Teleportation
Quantum teleportation is about moving the quantum state from one qubit to another qubit. This quantum state is not just the |0⟩ or |1⟩ states but includes every kind of superposition state.
A very important word in the previous paragraph is the word move. Quantum teleportation will not copy the quantum state, it will move or teleport it. A very important rule in quantum mechanics is the non-cloning theorem. This rule makes quantum computing more difficult because it cannot use classical error correction. In chapter 1, I talked about physical and logical qubits, where a single logical qubit is backed by many physical qubits to make sure the quantum state is as stable as possible using error correction. Since you are not able to copy a quantum state from one qubit to another, the only way to make that work is to repeat every operation you performed on a single qubit on the other qubits.
Because cloning a quantum state is not possible, teleporting a quantum state will invalidate the source qubit leaving it useless.
An example of this mind-boggling concept is the teleportation circuit visualized in the next figure.
Q# in 15-minutes
This part of the quick reference will give you some starters on the Q# programming language.
Quantum operations
A quantum operation is like a function or method in any other programming language, with the exception that it is used to perform a quantum operation: It should change the state of a qubit.
An operation starts with the keyword 'operation', followed by its unique name and a list of arguments in parentheses. There can be zero to multiple arguments, separated by a comma, and always formed by their name, followed by a colon and its datatype. The operation is always followed by a colon an the data type of its return value: Unit if there is nothing to return. Finally, the body of an operation is delimited by curly braces.
In the previous example you can see an operation with 'Solve' as its name, including a single argument 'a' of type Qubit and the Unit return type marking there is nothing to return.
The previous operation with the name 'Main' is the single entry point of your Q# application and it should be named 'Main' in order to work. You can use this in a Visual Studio Code *.qs file to start simulating quantum programs on your local machine.
If your operation should return a value, like for example a number represented by the Integer type, it will also need to return a compatible value at the end of its body, or at least in every branch of its execution path.
Working with qubits
A qubit is a special data type in Q#: Qubit. You need to allocate a single, or multiple, qubits in a use statement and think of them as a sparse resource.
Q# uses the Qubit() or Qubit[n] constructor to allocate a single or multiple qubits in an array.
Once an allocated qubit goes out of the scope where is was allocated (leaves the scope of a set of curly braces, like for example an operation) it will be freed by the runtime. One important think to know about this: You need to leave the qubit in its |0⟩ state. You can use the Reset or ResetAll operation to achieve this.
Gate logic
Most quantum gates are available in Q# as operations. To put a qubit in superposition, call the H-operation and feed the qubit variable as its argument.
Some operations accept multiple arguments and sometimes even multiple qubits. The following example allocates two qubits and entangles them using the CNOT-gate.
Working with variables
You can allocate other types of variables, both as immutable and mutable. After measuring a qubit for example, you will get a distinct collapsed state |0⟩ or |1⟩ as a result. The type of this state is 'Result' and can be stored in an immutable variable using the 'let' keyword.
You can also create mutable variables by using the 'mutable' and 'set' keywords and change their values after creation.
You can rewrite the previous logic in the following shorthand using a conditional expression.
Debugging
Since Q# runs in a simulated environment on your PC, you can use all kinds of debugging methods to see what is happening and learn what you are doing.
You can use 'Message' and string interpolation to write anything to the Terminal.
You can use 'DumpRegister' to write the actual state representation to the Terminal.
The above example will output the following table: