Esempio n. 1
0
 def neighbors_of(self, qubit: GridQubit):
     """Returns the qubits that the given qubit can interact with."""
     possibles = [
         GridQubit(qubit.row + 1, qubit.col),
         GridQubit(qubit.row - 1, qubit.col),
         GridQubit(qubit.row, qubit.col + 1),
         GridQubit(qubit.row, qubit.col - 1),
     ]
     return [e for e in possibles if e in self.qubits]
Esempio n. 2
0
 def at(self, row: int, col: int) -> Optional[GridQubit]:
     """Returns the qubit at the given position, if there is one, else None.
     """
     q = GridQubit(row, col)
     return q if q in self.qubits else None