Deutsch Jozsa algorithm
from qlasskit import qlassf, Qint
@qlassf
def f(a: Qint[4]) -> bool:
return a > 7
f.export("qiskit").draw("mpl")
![_images/e701c8c7d288b7c8b31d67bfd74640291b3169f82970a1c5a96fbc03e0bfef59.png](_images/e701c8c7d288b7c8b31d67bfd74640291b3169f82970a1c5a96fbc03e0bfef59.png)
from qlasskit.algorithms import DeutschJozsa
q_algo = DeutschJozsa(f)
qc = q_algo.export("qiskit")
qc.draw("mpl")
![_images/317b4a8fac0c5bc2bcd5ab20dd179c2a9240473def08b3ba93eb3b0d553781ea.png](_images/317b4a8fac0c5bc2bcd5ab20dd179c2a9240473def08b3ba93eb3b0d553781ea.png)
from qiskit import QuantumCircuit, transpile
from qiskit.visualization import plot_histogram
from qiskit_aer import AerSimulator
qc.measure_all()
simulator = AerSimulator()
circ = transpile(qc, simulator)
result = simulator.run(circ).result()
counts = result.get_counts(circ)
counts_readable = q_algo.decode_counts(counts)
plot_histogram(counts_readable)
![_images/5c37e1641175e805bd069b05b0507bee333663522ca9e04c1584a329607d7490.png](_images/5c37e1641175e805bd069b05b0507bee333663522ca9e04c1584a329607d7490.png)