function classicBitsAreValid(circuitState){
  let maxQbitIndex = getNoQbits(circuitState) - 1;
  for (let i = 0; i < circuitState.steps.length; i++) {
    let gates = circuitState.steps[i]["gates"];
    for (let j = 0; j < gates.length; j++) {
      let gate = gates[j];
      if (gate.name.includes("measure-")){
        if (gate.bit > maxQbitIndex) {
          return false;
        }
      }
    }
  }
  return true;
}
// the index of a classic bit cannot be larger than maximum qubit index
the index of a classic bit cannot be larger than maximum qubit index
the index of a classic bit cannot be larger than maximum qubit index
function classicBitsAreValid(circuitState){
  let maxQbitIndex = getNoQbits(circuitState) - 1;
  for (let i = 0; i < circuitState.steps.length; i++) {
    let gates = circuitState.steps[i]["gates"];
    for (let j = 0; j < gates.length; j++) {
      let gate = gates[j];
      if (gate.name.includes("measure-")){
        if (gate.bit > maxQbitIndex) {
          return false;
        }
      }
    }
  }
  return true;
}
function classicBitsAreValid ( circuitState ) { let maxQbitIndex = getNoQbits ( circuitState ) - 1 ; for ( let i = 0 ; i < circuitState . steps . length ; i ++ ) { let gates = circuitState . steps [ i ] [ "gates" ] ; for ( let j = 0 ; j < gates . length ; j ++ ) { let gate = gates [ j ] ; if ( gate . name . includes ( "measure-" ) ) { if ( gate . bit > maxQbitIndex ) { return false ; } } } } return true ; }
the index of a classic bit cannot be larger than maximum qubit index
the index of a classic bit cannot be larger than maximum qubit index