Skip to content

ryanhill1/qBraid-qiskit-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

qBraid-qiskit-challenge

In this coding challenge, your task is to write a program that generates the qiskit source code for a given qiskit.QuantumCircuit object.

For example, let's say I create a random qiskit circuit:

>>> from qiskit.circuit.random import random_circuit
>>> qc = random_circuit(num_qubits=2, depth=3)
>>> qc.draw()
          ┌────────────┐┌───┐
q_0: ──■──┤ Rz(4.6866) ├┤ H ├
     ┌─┴─┐└──┬─────┬───┘└─┬─┘
q_1: ┤ H ├───┤ Sdg ├──────■──
     └───┘   └─────┘         

When this or any other circuit object is passed to your program, it should output a .py file containing qiskit code that could accuractely recreate the circuit. For the above example, the output file could look as follows:

# program_output.py

from qiskit import QuantumRegister, QuantumCircuit

qreg_q = QuantumRegister(2, 'q')

circuit = QuantumCircuit(qreg_q)

circuit.ch(qreg_q[0], qreg_q[1])
circuit.rz(4.6865553, qreg_q[0])
circuit.sdg(qreg_q[1])
circuit.ch(qreg_q[1], qreg_q[0])

If someone copy and pasted the output code back into the same notebook, they should find that the two circuit objects are equivalent. For this task, you can restrict yourself to processing only gates and operations that are able to be generated by the qiskit.circuit.random.random_circuit function.

The way you architect and/or deliver your solution (i.e. as a script, package, single function, or other) is up to you, and you can use any external packages you wish.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published