B1. Increment
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Implement a unitary operation on a register of $N$ qubits that increments the number written in the register modulo $2^N$.

Your operation should take a register of type LittleEndian - an array of qubits that encodes an unsigned integer in little-endian format, with the least significant bit written first (corresponding to the array element with index 0). The "output" of your solution is the state in which it left the input qubits.

For example, if the qubits passed to your operation are in the state $\frac{1}{\sqrt{2}}(|11\rangle + |10\rangle) = \frac{1}{\sqrt{2}}(|3\rangle + |1\rangle)$, they should be transformed to the state $\frac{1}{\sqrt{2}}(|(3+1) \mod 2^2\rangle + |(1+1) \mod 2^2\rangle) = \frac{1}{\sqrt{2}}(|0\rangle + |2\rangle) = \frac{1}{\sqrt{2}}(|00\rangle + |01\rangle)$.

Your code should have the following signature (note that your operation should have Adjoint and Controlled variants defined for it; is Adj+Ctl in the operation signature will generate them automatically based on your code):

namespace Solution {    open Microsoft.Quantum.Arithmetic;    open Microsoft.Quantum.Intrinsic;    operation Solve (register : LittleEndian) : Unit is Adj+Ctl {        // your code here    }}

Your code is not allowed to use measurements or arbitrary rotation gates (so, for example, using the library operation IncrementByInteger will cause runtime error). This operation can be implemented using just the X gate and its controlled variants.