{"id":25407920,"url":"https://github.com/teomandeniz/qasm-examples","last_synced_at":"2026-01-31T23:12:41.824Z","repository":{"id":262539978,"uuid":"887559967","full_name":"TeomanDeniz/QASM-Examples","owner":"TeomanDeniz","description":"Exercises For Programing a Quantum Computer With Quantum Inspire's Own QASM Language","archived":false,"fork":false,"pushed_at":"2024-12-17T23:24:33.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T11:58:10.898Z","etag":null,"topics":["qasm","quantum-computing"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TeomanDeniz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-12T22:14:55.000Z","updated_at":"2025-01-27T11:54:00.000Z","dependencies_parsed_at":"2024-11-18T06:35:41.941Z","dependency_job_id":null,"html_url":"https://github.com/TeomanDeniz/QASM-Examples","commit_stats":null,"previous_names":["teomandeniz/qasm-examples"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TeomanDeniz%2FQASM-Examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TeomanDeniz%2FQASM-Examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TeomanDeniz%2FQASM-Examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TeomanDeniz%2FQASM-Examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TeomanDeniz","download_url":"https://codeload.github.com/TeomanDeniz/QASM-Examples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248710435,"owners_count":21149188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["qasm","quantum-computing"],"created_at":"2025-02-16T07:19:23.188Z","updated_at":"2026-01-31T23:12:36.773Z","avatar_url":"https://github.com/TeomanDeniz.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# QASM Examples\n\n* Note: I'll update this readme during my research and tests.\n\nSome exercises for Programing Quantum Computer with QASM Language from **[Quantum Inspire](https://www.quantum-inspire.com/)**.\n\nFirst of all:\n\n* There are qubits. They are bits of Quantum Computer and work same as original bits. (If we want of course)\n* You gonna see this $`∣\\psi⟩`$ fromula often. Means our qubit's value. Which also `ψ` can be `0` or `1`. Or **both**... Scary right? Also this formula called **Quantum State Notation**.\n\n## Version Declaration\n\n```qasm\nVERSION 1.0\n```\n\nThis line indicates the version of QASM being used. If you're aiming for more recent features like custom subroutines or control structures, you'd specify a later version, like `3.0`.\n\n\n## Comment Line\n\nYou can create comment lines with `#` character like in original ASM.\n\n```qasm\n# This is a comment line\n```\n\n## Qubit Declaration\n\n```qasm\nQUBITS 3\n```\n\nThis declares the number of qubits (three) that you'll use in your program.\n\nLike classical bits, a single qubit is the smallest unit of information in a quantum computer, representing either a 0 or a 1.\n\nHowever, due to superposition, a qubit can represent 0, 1, or both at once in a probabilistic combination. Mathematically, it’s represented as:\n\n$$\n∣\\psi⟩=\\alpha∣0⟩+\\beta∣1⟩\n$$\n\nwhere α and β are probability amplitudes, and $`\\left|\\alpha\\right|^{2}+\\left|\\beta\\right|^{2}=1`$\n\n* In QASM, qubits are usually declared as a register, e.g., `qreg q[3];` in QASM 2.0 or 3.0. This line would look like:\n\n```qasm\nQREG Q[3];\n```\n\n* If syntax doesn't recognize `qubit 3`, we may need to change it to this form to make it compatible with standard QASM (version 1.0).\n\n## Sections\n\nSections are like comment lines or functions in QASM. They may not work like original ASM but syntax is same.\n\n```qasm\n.section_name\n\t...\n```\n\nAlso, QASM doesn’t natively support labeled sections.\n\n## Preparation Phase\n\n```qasm\nPREP_Z Q[0:2]\n```\n\n`PREP_Z` is preparing qubits in the `|0⟩` state using the **Z** operation or as a shorthand for **preparing in the standard state `∣0⟩`** (which is the ground state of a qubit).\n\nAnd `Q[0:2]` is represents as: `qubit 0`, `qubit 1`, and `qubit 2`.\n\n## Hadamard Gate\n\n```qasm\nH Q[0];\n```\n\nThis command puts your qubit(s) into a superposition state $`\\frac{|0\u003e + |1\u003e}{\\sqrt{2}}`$.\n\nWithout that, our qubit will act like normal bits. (Like 1 or 0).\n\nBut with that, our qubit act like it's both 1 or 0.\n\nNow, you may ask: ***WHY???***\n\nSetting a qubit into a **superposition state** is fundamental to how quantum computers work and why they have the potential to outperform classical computers in certain tasks.\n\nFor example, we have a `int data[4000000]` and we need to find a single byte from this large data. In a normal code, we actually need to search this byte in a loop one by one. But with this setup, our Quantum Computer finds the data we are looking for **MUTCH mutch faster** than normally (At least tries). Because that qubit is act like it's everywhere.\n\nAlso, `22` qubits are enugh for searching a value within **4.000.000** items. ($`2^{22} = `$`4,194,304`)\n\nFor another example, let's call the size of our item **`N`** (`for (int index = 0; index \u003c N; index++)`). When we are looking for a data, it's going to be look for this data from an item for **$`O\\left(N\\right)`$** times. But for qubics with `H` command, it's going to be **$`O\\left(\\sqrt{N}\\right)`$** times which is faster but not instantaneous. ($`\\sqrt{4000000}=2000`$)\n\nFor more info:\n\n* **Parallelism** (Quantum Parallelism)\n  * When a qubit is in a superposition of states (e.g., $`\\frac{1}{\\sqrt{2}}(∣0⟩ + ∣1⟩)`$), it can represet both the `∣0⟩` and `∣1⟩` states simultaneously.\n  * This allows quantum computers to process multiple possibilities at the same time. In classical computing, a bit can only be in one of two states, either 0 or 1, at any given moment. A quantum bit (qubit), on the other hand, can hold an infinite number of potential outcomes, thanks to superposition.\n  * For example, a quantum computer with n qubits can represent all $`2^{n}`$ possible states at once, exponentially increasing the amount of information that can be processed simultaneously.\n* **Interference**\n  * Superposition enables **quantum interference**, where different superpositions of qubits can combine (interfere) with each other.\n  * **Constructive interference** can amplify the probability of correct answers, and **destructive interference** can cancel out incorrect ones. Quantum algorithms like **Grover's search algorithm** or **Shor’s factoring algorithm** rely on this interference to find solutions more efficiently than classical methods.\n* **Quantum Entanglement**\n  * Superposition is often combined with **entanglement**, where qubits are correlated with each other in ways that classical bits cannot be.\n  * Entangled qubits are in a superposition of states that are \u003cINS\u003edependent\u003c/INS\u003e on each other, even if the qubits are far apart. This is the foundation of algorithms like **quantum teleportation** and **quantum cryptography**.\n  * In many quantum algorithms, superposition and entanglement work together to solve problems that would otherwise be intractable for classical computers.\n\n## **X Gate** (also called Pauli-X Gate or NOT Gate)\n\nX gate is simple flips the value of a qubit.\n\nLike: `|0\u003e` to `|1\u003e` or `|1\u003e` to `|0\u003e`.\n\nFor example:\n\n```qasm\n# Q[1] IS |0\u003e\nX Q[1]\n# Q[1] IS |1\u003e\nX Q[1]\n# Q[1] IS |0\u003e\n```\n\nMatrix representation:\n\n$$\nX=\\left[\n\\begin{array}{cccc}\n0 \u0026 1 \\\\\n1 \u0026 0\n\\end{array}\n\\right]\n$$\n\n## **Controlled-NOT**\n\nLet's just select `Q[0]` and  `Q[2]` qubits for this command.\n\n```qasm\nCNOT Q[0], Q[2]\n```\n\n`CNOT` is flips `Q[2]` qubit if `Q[0]` **NOT** `|0\u003e`.\n\n\"*Flip*\" by I mean, `|0\u003e` to `|1\u003e` or `|1\u003e` to `|0\u003e`.\n\n| CONTROL (Q0) | TARGET (Q2) | RESULT OF (Q2) AFTER `CNOT` |\n| -----------: | :---------: | :-------------------------- |\n| 0            | 0           | 0                           |\n| 0            | 1           | 1                           |\n| 1            | 0           | 1                           |\n| 1            | 1           | 0                           |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteomandeniz%2Fqasm-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteomandeniz%2Fqasm-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteomandeniz%2Fqasm-examples/lists"}