This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import cirq | |
import numpy as np | |
def fresh_attempt() -> int: | |
a, b = cirq.LineQubit.range(2) | |
h_cx_cs_h = cirq.unitary(cirq.Circuit(cirq.H(b), cirq.X(a).controlled_by(b), cirq.S(a).controlled_by(b), cirq.H(b))) | |
check_output_tdag_h = cirq.unitary(cirq.Circuit(cirq.T(a) ** -1, cirq.H(a))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Quirk testing URL: | |
# https://algassert.com/quirk#circuit=%7B%22cols%22%3A%5B%5B%22H%22%2C%22H%22%2C%22H%22%2C%22H%22%2C%22H%22%5D%2C%5B%22%E2%80%A2%22%2C1%2C1%2C1%2C1%2C%22X%22%5D%2C%5B1%2C%22%E2%80%A2%22%2C1%2C1%2C1%2C1%2C%22X%22%5D%2C%5B1%2C1%2C%22%E2%80%A2%22%2C1%2C1%2C1%2C1%2C%22X%22%5D%2C%5B1%2C1%2C1%2C%22%E2%80%A2%22%2C1%2C1%2C1%2C1%2C%22X%22%5D%2C%5B1%2C1%2C1%2C1%2C%22%E2%80%A2%22%2C1%2C1%2C1%2C1%2C%22X%22%5D%2C%5B%22xpar%22%2C%22zpar%22%2C%22xpar%22%2C%22xpar%22%2C1%2C%220%22%5D%2C%5B%22Measure%22%5D%2C%5B%22zpar%22%2C1%2C%22zpar%22%2C%22xpar%22%2C%22zpar%22%2C%220%22%5D%2C%5B1%2C1%2C1%2C1%2C%22H%22%5D%2C%5B1%2C1%2C1%2C1%2C%22Measure%22%5D%2C%5B%22zpar%22%2C%22xpar%22%2C%22xpar%22%2C1%2C%22zpar%22%2C%220%22%5D%2C%5B1%2C%22Measure%22%5D%2C%5B1%2C%22zpar%22%2C%22zpar%22%2C%22zpar%22%2C%22zpar%22%2C%220%22%5D%2C%5B1%2C1%2C1%2C%22H%22%5D%2C%5B1%2C1%2C1%2C%22Measure%22%5D%2C%5B1%2C1%2C1%2C1%2C1%2C%22xpar%22%2C%22zpar%22%2C%22xpar%22%2C%22xpar%22%2C1%2C1%2C1%2C1%2C1%2C1%2C%22X%22%5D%2C%5B1%2C1%2C1%2C1%2C1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Iterable, Tuple | |
import time | |
import numpy as np | |
def to_mask(word: str) -> int: | |
"""Converts a word into a bitmask where each bit indicates presence of a letter.""" | |
t = 0 | |
for c in word: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
import stim | |
def circuit_to_tableau(circuit: stim.Circuit) -> stim.Tableau: | |
s = stim.TableauSimulator() | |
s.do_circuit(circuit) | |
return s.current_inverse_tableau() ** -1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional, Dict | |
import cirq | |
def compose(*gates: cirq.Gate) -> cirq.Gate: | |
matrix = cirq.unitary(gates[0]) | |
for g in gates[1:]: | |
matrix = cirq.unitary(g) @ matrix | |
return cirq.MatrixGate(matrix) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
import math | |
import itertools | |
def evaluate_circuit(gates, initial_bits=None): | |
""" | |
:param gates: [( [controls], [targets] )] | |
:param initial_bits: set(on_bits) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script> | |
let canvas = document.createElement('canvas'); | |
document.body.appendChild(canvas); | |
let gl = canvas.getContext('webgl'); | |
if (!gl) { | |
throw new Error("!gl") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<title>WebXR Testing</title> | |
</head> | |
<body> | |
<input id="button_enter" type="button" value="Loading..." disabled/> | |
<script> | |
const GL = WebGLRenderingContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional, List, Dict, Callable, Any | |
from collections import defaultdict | |
import fractions | |
import math | |
import random | |
import sys | |
import matplotlib.pyplot as plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def persistence(n): | |
t = 0 | |
while n >= 10: | |
t += 1 | |
n2 = 1 | |
for d in str(n): | |
n2 *= int(d) | |
n = n2 | |
return t |