Sounds like you want a quantum "Hello World". The most straightforward quantum version of this would just be to write a binary encoded version of the text Hello World
in a register of qubits. But this would require ~100 qubits, and be longer than your upper limit for code length.
So let's write a shorter peice of text. Let's write ;)
, we need a bit string of length 16. Specifically, using ASCII encoding
;) = 00111011 00101001
Using QISKit, you'd do this using the following code.
from qiskit import QuantumProgram
import Qconfig
qp = QuantumProgram()
qp.set_api(Qconfig.APItoken, Qconfig.config["url"]) # set the APIToken and API url
# set up registers and program
qr = qp.create_quantum_register('qr', 16)
cr = qp.create_classical_register('cr', 16)
qc = qp.create_circuit('smiley_writer', [qr], [cr])
# rightmost eight (qu)bits have ')' = 00101001
qc.x(qr[0])
qc.x(qr[3])
qc.x(qr[5])
# second eight (qu)bits have 00111011
# these differ only on the rightmost two bits
qc.x(qr[9])
qc.x(qr[8])
qc.x(qr[11])
qc.x(qr[12])
qc.x(qr[13])
# measure
for j in range(16):
qc.measure(qr[j], cr[j])
# run and get results
results = qp.execute(["smiley_writer"], backend='ibmqx5', shots=1024)
stats = results.get_counts("smiley_writer")
Of course, this isn't very quantum. So you could do a superposition of two different emoticons instead. The easiest example is to superpose ;) with 8), since the bit strings for these differ only on qubits 8 and 9.
;) = 00111011 00101001
8) = 00111000 00101001
So you can simply replace the lines
qc.x(qr[9])
qc.x(qr[8])
from the above with
qc.h(qr[9]) # create superposition on 9
qc.cx(qr[9],qr[8]) # spread it to 8 with a cnot
The Hadamard creates a superposition of 0
and 1
, and the cnot makes it into a superposition of 00
and 11
on two qubits. This is the only required superposition for ;)
and 8)
.
If you want to see an actual implementation of this, it can be found on the QISKit tutorial (full disclosure: it was written by me).