Coding Sandbox
How the browser-based coding environment works, from writing Qiskit circuits to understanding execution and results.
On this page
The Code Editor
The coding sandbox uses a Monaco-based editor (the same engine behind VS Code) directly in your browser. No local setup or installation is required.
Editor Features
Syntax Highlighting
Full Python syntax highlighting with Qiskit keyword recognition.
Resizable Layout
Drag the divider between the instructions panel and editor to adjust the split.
Starter Code
Each challenge preloads a template with imports and a solution() skeleton.
No Copy-Paste
Pasting code into the editor is disabled. Solutions must be written from scratch.
Writing Circuits in Qiskit
All challenges use Qiskit, IBM's open-source Python framework for quantum computing. Your code runs as standard Python with full access to the Qiskit library.
Basic Pattern
Every solution follows the same structure:
from qiskit import QuantumCircuit
def solution():
qc = QuantumCircuit(2) # Create a circuit with 2 qubits
qc.h(0) # Apply Hadamard to qubit 0
qc.cx(0, 1) # Apply CNOT with control=0, target=1
return qc # Return the circuitCommonly Used Gates
| Gate | Qiskit Method | Description |
|---|---|---|
| Hadamard | qc.h(qubit) | Creates superposition |
| Pauli-X | qc.x(qubit) | Bit flip (NOT gate) |
| Pauli-Z | qc.z(qubit) | Phase flip |
| CNOT | qc.cx(ctrl, tgt) | Controlled-NOT |
| CZ | qc.cz(ctrl, tgt) | Controlled-Z |
| SWAP | qc.swap(q1, q2) | Swap two qubits |
| Rx | qc.rx(theta, qubit) | X-axis rotation |
| Ry | qc.ry(theta, qubit) | Y-axis rotation |
| Rz | qc.rz(theta, qubit) | Z-axis rotation |
| Toffoli | qc.ccx(c1, c2, tgt) | Double-controlled NOT |
Do not add measurements
The platform handles measurement automatically using a statevector simulator. Do not add qc.measure() or measurement gates to your circuit unless a challenge specifically instructs you to.
How Execution Works
When you run or submit code, it is sent to an isolated server-side execution environment. Here is the full pipeline.
1.Code Submission
Your code is sent to the server. An attempt record is created and queued for execution.
2.Sandbox Creation
A fresh, isolated container is provisioned specifically for your attempt. Each execution gets its own environment with no shared state.
3.Circuit Execution
Your Python code is executed inside the container. The solution() function is called, and the returned QuantumCircuit is run on the Qiskit statevector simulator.
4.Test Evaluation
The simulator output is compared against each test case's expected probability distribution. Results are compiled into a score.
5.Results Delivery
Results stream back to your browser in real time. You see progress updates as each stage completes: setup, running, testing, and final results.
Resource Limits
Run vs Submit
There are two ways to execute your code, and the distinction matters.
Run
- Executes your code against all test cases
- Shows full results and feedback
- Does not count as an official attempt
- Does not affect your score or medals
- Does not award XP
- Use this to test and iterate freely
Submit
- Executes your code as an official attempt
- Records your score and completion time
- Awards medals based on performance
- Grants XP for completions and improvements
- Counts toward leaderboard rankings
- Use this when you are confident in your solution
Recommendation
Always use Run first to verify your solution passes all tests. Once you are satisfied with the results, use Submit to make it official.
Interpreting Results
After execution, you receive detailed feedback. Here is how to read each part.
Overall Score
A percentage (0-100) representing how many test points your circuit passed. A score of 95 means 95% of test points were satisfied.
Test Results
Each test case is listed individually, showing whether it passed or failed. For failed tests, you can see the expected output versus what your circuit produced.
Expected vs Actual
Expected values show the target probability distribution. Actual values show what your circuit produced. The difference must be within the tolerance threshold.
Medal Award
If your score and completion time meet the threshold, a medal is displayed. Your best medal is saved and shown on the challenge card.
XP Earned
For submissions, any XP earned is shown with an overlay animation. XP is calculated based on completion status, score improvement, and medal achievement.
Sandbox Security
Every code execution runs in a fully isolated environment. This ensures fair evaluation and protects the platform.
Isolated Containers
Each attempt runs in a fresh container with no shared state. Your code cannot access other users' data or previous submissions.
Network Isolation
Containers have no external network access. Your code cannot make HTTP requests or access external services.
Read-Only Filesystem
The container filesystem is read-only except for a temporary directory. This prevents persistent modifications.
Resource Limits
Memory, CPU, and process limits prevent resource exhaustion. Fork bombs and infinite loops are contained.