An educational Qiskit notebook that explores how a quantum circuit can compare two signed integers and return the larger value. The project was completed as a screening task for the Quantum Open Software Foundation (QOSF).
The notebook:
- Encodes each input integer as a sign bit plus a zero-padded binary magnitude.
- Initializes corresponding qubits with X gates for set bits.
- Applies comparison logic using CNOT and Toffoli-based oracle operations.
- Uses multi-controlled X gates to consolidate the comparison result into an output qubit.
- Measures the output on Qiskit Aer’s
qasm_simulatorand maps the measured result back to the larger input.
LargestNumber.ipynb— the complete experiment, circuit construction, simulation, and sample execution.
- Python
- Qiskit
- Qiskit Aer simulator
- Create a Python environment with a Qiskit version compatible with the notebook’s
QuantumCircuit,Aer, andexecuteimports. - Install Qiskit and its Aer simulator.
- Open
LargestNumber.ipynbin Jupyter and run the cells in order.
This is an experimental learning project rather than a production comparator. Its value is in the circuit design: representing signed binary inputs, composing controlled operations, and validating the output through simulation.
- Add a conventional test suite covering positive, negative, and equal inputs.
- Refactor the circuit into reusable, parameterized gates.
- Update the notebook for current Qiskit APIs and document complexity limits.