%matplotlib inline
from qiskit import *

circuit = QuantumCircuit(5, 2)

# Steps to change qubits to 1 for test purposes
_ = circuit.x(0)
_ = circuit.x(1)
_ = circuit.x(2)
_ = circuit.barrier()

_ = circuit.ccx(0, 1, 3)
circuit.draw(output="mpl")

_ = circuit.ccx(2, 3, 4)
circuit.draw(output="mpl")

_ = circuit.ccx(0, 1, 3)
circuit.draw(output="mpl")

# Measure (x^y^z) and working qubuit in classical bit
_ = circuit.barrier()
_ = circuit.measure(4, 0)
_ = circuit.measure(3, 1)

circuit.draw(output="mpl")

# Simulate
simulator = Aer.get_backend("qasm_simulator")
job = execute(circuit, backend=simulator, shots=1024)
result = job.result()
counts = result.get_counts()

# Plot results
visualization.plot_histogram(counts)