def _permutation_making_qubits_adjacent(qubit_indices, num_qubits):
    """Given an iterable of qubit indices construct a permutation such that they are
    next to each other."""
    return list(qubit_indices) + [
        i for i in range(num_qubits) if i not in qubit_indices
    ]