Wow, you really do just put the word Quantum in front of everything.
Unknown
Wow, you really do just put the word Quantum in front of everything.
Unknown
Wow, you really do just put the word Quantum in front of everything.
Unknown
Go to your computer, Craig.
Unknown
Wow, you really do just put the word Quantum in front of everything.
Unknown
Go to your computer, Craig.
Unknown
Wow, you really do just put the word Quantum in front of everything.
Unknown
Go to your computer, Craig.
Unknown
Wow, you really do just put the word Quantum in front of everything.
Unknown
Go to your computer, Craig.
Unknown
HI CRAIG IT'S
It's Scott, Ant-Man, whatever, hey I need your help. 🐜
Unknown
It's Scott, Ant-Man, whatever, hey I need your help. 🐜
Unknown
Hurry up it's important. 🐜
Scott Lang
HI CRAIG IT'S
It's Scott, Ant-Man, whatever, hey I need your help. 🐜
Unknown
Hurry up it's import🐜. 🐜
Scott Lang
HI CRAIG IT'S
It's Scott, Ant-Man, whatever, hey I need your help. 🐜
Unknown
Hurry up it's import🐜. 🐜
Scott Lang
HI CRAIG IT'S
It's Scott, Ant-Man, whatever, hey I need your help. 🐜
Unknown
Hurry up it's import🐜. 🐜
Scott Lang
I am in the middle of a talk.
Reply:
HI CRAIG IT'S
It's Scott, Ant-Man, whatever, hey I need your help. 🐜
Unknown
Hurry up it's import🐜. 🐜
Scott Lang
I am in the middle of a talk.
Reply:
HI CRAIG IT'S
It's Scott, Ant-Man, whatever, hey I need your help. 🐜
Unknown
Hurry up it's import🐜. 🐜
Scott Lang
I am in the middle of a talk.
Reply:
HI CRAIG IT'S
It's Scott, Ant-Man, whatever, hey I need your help. 🐜
Unknown
Hurry up it's important. 🐜
Scott Lang
I am in the middle of a talk.
Reply:
HI CRAIG IT'S
I KNOW! That's why I need you. Teach the nice people about Qubits and I'll be in touch. 🐜
Scott Lang
It's Scott, Ant-Man, whatever, hey I need your help. 🐜
Unknown
HI CRAIG IT'S
I KNOW! That's why I need you. Teach the nice people about Qubits and I'll be in touch. 🐜
Scott Lang
It's Scott, Ant-Man, whatever, hey I need your help. 🐜
Unknown
I KNOW! That's why I need you. Teach the nice people about Qubits and I'll be in touch. 🐜
Scott Lang
HI CRAIG IT'S
It's Scott, Ant-Man, whatever, hey I need your help. 🐜
Unknown
OH AND I'M IN YOUR JAVASCRIPT
🐜🐜🐜🐜🐜🐜🐜🐜🐜🐜
🐜🐜🐜🐜🐜🐜🐜🐜🐜🐜
🐜🐜🐜🐜🐜🐜🐜🐜🐜🐜
🐜🐜🐜🐜🐜🐜🐜🐜🐜🐜
🐜🐜🐜🐜🐜🐜🐜🐜🐜🐜
🐜🐜🐜🐜🐜🐜🐜🐜🐜🐜
0
10
0110
11010110
0011101011010110
00101111100101100011101011010110
0010111110010110001110101101011000101111100101100011101011010110
const psi = [
probabilityA,
probabilityB
];
const psi = [
complex(1 / Math.sqrt(2), 0), // { r: 0.7071067812, i: 0 }
complex(0, 1 / Math.sqrt(2)) // { r: 0, i: 0.7071067812 }
];
Oh cool, maths. Okay here's the deal, I'm locked up in the Quantum Realm, and I need you to help me get out. 🐜
Scott Lang
type Complex = [number, number];
type Row = Array<Complex>;
type Matrix = Array<Row>;
function complex (r = 0, i = 0): Complex {
return [r, i];
}
function kZero(): Matrix {
return [[complex(1)], [complex(0)]];
}
function kOne(): Matrix {
return [[complex(0)], [complex(1)]];
}
Oh cool, maths. Okay here's the deal, I'm locked up in the Quantum Realm, and I need you to help me get out. 🐜
Scott Lang
type Complex = [number, number];
type Row = Array<Complex>;
type Matrix = Array<Row>;
function complex (r = 0, i = 0): Complex {
return [r, i];
}
function kZero(): Matrix {
return [[complex(1)], [complex(0)]];
}
function kOne(): Matrix {
return [[complex(0)], [complex(1)]];
}
It's Scott, Ant-Man, whatever, hey I need your help. 🐜
Unknown
Someone knocked me out, and I woke up in a prison cell. 🐜
Scott Lang
Someone knocked me out, and I woke up in a prison cell. 🐜
Scott Lang
BUT I accessed the system that controls the locks, and entangled myself with your CPU...
Scott Lang
Someone knocked me out, and I woke up in a prison cell. 🐜
Scott Lang
BUT I accessed the system that controls the locks, and entangled myself with your CPU...
Scott Lang
So I can send you messages and run code. 🐜
Scott Lang
Someone knocked me out, and I woke up in a prison cell. 🐜
Scott Lang
BUT I accessed the system that controls the locks, and entangled myself with your CPU...
Scott Lang
So I can send you messages and run code. 🐜
Scott Lang
Someone knocked me out, and I woke up in a prison cell. 🐜
Scott Lang
BUT I accessed the system that controls the locks, and entangled myself with your CPU...
Scott Lang
So I can send you messages and run code. 🐜
Scott Lang
Someone knocked me out, and I woke up in a prison cell. 🐜
Scott Lang
BUT I accessed the system that controls the locks, and entangled myself with your CPU...
Scott Lang
So I can send you messages and run code. 🐜
Scott Lang
Someone knocked me out, and I woke up in a prison cell. 🐜
Scott Lang
So I can send you messages and run code. 🐜
Scott Lang
Shit, someone's coming, one sec. 🐜
Scott Lang
Someone knocked me out, and I woke up in a prison cell. 🐜
Scott Lang
So I can send you messages and run code. 🐜
Scott Lang
Shit, someone's coming, one sec. 🐜
Scott Lang
const bit: boolean = false;
console.log(bit); // false
function normalise(ket: Matrix): KeMatrixt {
const flat = ket.map(([c]) => c);
const total = flat.reduce((sum,[re,im])=>sum+re*re+im*im,0);
return flat.map(([re,im])=>[re/Math.sqrt(total), im/Math.sqrt(total)]);
}
function measure(ket: Matrix): Matrix {
const normalised = normalise(ket);
const probabilities = normalised.map(([re, im]) => re*re + im*im);
const cumulative = [];
probabilities.reduce((acc, p, i) => {
cumulative[i] = acc + p;
return acc + p;
}, 0);
const r = Math.random();
for (let i = 0; i < cumulative.length; i++) {
if (r < cumulative[i]) return i;
}
return cumulative.length - 1;
}
const psi = [
[complex(1, 0)],
[complex(0, 0)]
];
measure(psi); // 0
measure(psi); // 0
measure(psi); // 0
measure(psi); // 0
const psi = [
[complex(1 / Math.sqrt(2), 0)],
[complex(0, 1 / Math.sqrt(2))]
];
measure(psi); // 0
measure(psi); // 1
measure(psi); // 0
measure(psi); // 0
measure(psi); // 1
measure(psi); // 1
const psi = [
[complex(1 / Math.sqrt(2), 0)],
[complex(0, 0)],
[complex(0, 0)],
[complex(1 / Math.sqrt(2), 0)]
];
CRAIG. 🐜
Scott Lang
measure(psi); // 00
measure(psi); // 11
measure(psi); // 11
measure(psi); // 00
const psi = [
[complex(0, 0)],
[complex(0, 0)],
[complex(1 / Math.sqrt(2), 0)],
[complex(1 / Math.sqrt(2), 0)]
];
CRAIG. 🐜
Scott Lang
measure(ignore(psi, 1)); // 0
measure(ignore(psi, 1)); // 0
measure(ignore(psi, 1)); // 0
measure(ignore(psi, 1)); // 0
CRAIG. 🐜
Scott Lang
function ignore(ket: Matrix, n: number): Matrix {
const normalized = normalise(ket);
const size = normalized.length;
const chunkSize = Math.pow(2, n);
const newKet: Ket = [];
for (let i = 0; i < size / chunkSize; i++) {
let sumProb = 0;
for (let p = i * chunkSize; p < (i + 1) * chunkSize; p++) {
const [re, im] = normalized[p];
sumProb += re * re + im * im;
}
newKet.push([[Math.sqrt(sumProb), 0]]);
}
return newKet;
}
CRAIG. 🐜
Scott Lang
measure(psi); // 00
measure(psi); // 11
measure(psi); // 11
measure(psi); // 00
CRAIG. 🐜
Scott Lang
const psi = [
[complex(1 / Math.sqrt(2), 0)],
[complex(0, 0)],
[complex(0, 0)],
[complex(1 / Math.sqrt(2), 0)]
];
CRAIG. 🐜
Scott Lang
CRAIG. 🐜
Scott Lang
CRAIG. 🐜
Scott Lang
measure(psi); // 00
measure(psi); // 11
measure(psi); // 11
measure(psi); // 00
const psi = [
[complex(1 / Math.sqrt(2), 0)],
[complex(0, 0)],
[complex(0, 0)],
[complex(1 / Math.sqrt(2), 0)]
];
CRAIG. 🐜
Scott Lang
CRAIG. 🐜
Scott Lang
measure(psi); // 00
measure(psi); // 11
measure(psi); // 11
measure(psi); // 00
CRAIG. 🐜
Scott Lang
const psi = [
[complex(1 / Math.sqrt(2), 0)],
[complex(0, 0)],
[complex(0, 0)],
[complex(1 / Math.sqrt(2), 0)]
];
QUANTUM SECURITY CAM_1
I've made some progress! I've got access to the Quantum security system computer! 🐜
Scott Lang
CRAIG. 🐜
Scott Lang
CRAIG. 🐜
Scott Lang
CRAIG. 🐜
Scott Lang
QUANTUM SECURITY CAM_1
I've made some progress! I've got access to the Quantum security system computer! 🐜
Scott Lang
Darn it, there's three layers of security to get this door open. 🐜
Scott Lang
Darn it, there's three layers of security to get this door open. 🐜
Scott Lang
I'm going to try something quickly. 🐜
Scott Lang
Darn it, there's three layers of security to get this door open. 🐜
Scott Lang
I'm going to try something quickly. 🐜
Scott Lang
QUANTUM SECURITY CAM_1
function mIdentity (n: number = 1): Matrix {
const size = Math.pow(2, n);
return Array.from({ length: size }, (_, row) =>
Array.from({ length: size }, (_, column) => complex(row === column ? 1 : 0))
);
}
function mHadamard(): Matrix {
const oneOverRoot2 = 1 / Math.sqrt(2);
return [
[complex(oneOverRoot2), complex(oneOverRoot2)],
[complex(oneOverRoot2), complex(-oneOverRoot2)],
];
}
const H = mHadamard()
const psi = kZero();
const Hpsi = [
[H[0][0] * psi[0] + H[0][1] * psi[1]],
[H[1][0] * psi[0] + H[1][1] * psi[1]]
];
console.log(Hpsi);
// [[0.7071067811865475], [0.7071067811865475]]
const zero = kZero(); // [[1], [0]]
const one = kOne(); // [[0], [1]]
const zeroKronOne = [
[zero[0] * one[0]],
[zero[0] * one[1]],
[zero[1] * one[0]],
[zero[1] * one[1]]
];
console.log(zeroKronOne); // [[0], [1], [0], [0]]
const H = mHadamard();
const HkronH = [
[
H[0][0] * H[0][0], H[0][0] * H[0][1],
H[0][1] * H[0][0], H[0][1] * H[0][1]
],
[
H[0][0] * H[1][0], H[0][0] * H[1][1],
H[0][1] * H[1][0], H[0][1] * H[1][1]
],
[
H[1][0] * H[0][0], H[1][0] * H[0][1],
H[1][1] * H[0][0], H[1][1] * H[0][1]
],
[
H[1][0] * H[1][0], H[1][0] * H[1][1],
H[1][1] * H[1][0], H[1][1] * H[1][1]
]
];
const H = mHadamard();
const HkronH = [
[
H[0][0] * H[0][0], H[0][0] * H[0][1],
H[0][1] * H[0][0], H[0][1] * H[0][1]
],
[
H[0][0] * H[1][0], H[0][0] * H[1][1],
H[0][1] * H[1][0], H[0][1] * H[1][1]
],
[
H[1][0] * H[0][0], H[1][0] * H[0][1],
H[1][1] * H[0][0], H[1][1] * H[0][1]
],
[
H[1][0] * H[1][0], H[1][0] * H[1][1],
H[1][1] * H[1][0], H[1][1] * H[1][1]
]
];
function cAdd(c1: Complex, c2: Complex): Complex {
const [c1r, c1i] = c1;
const [c2r, c2i] = c2;
return [c1r + c2r, c1i + c2i];;
}
function cMultiply(c1: Complex, c2: Complex): Complex {
const [c1r, c1i] = c1;
const [c2r, c2i] = c2;
return [
c1r * c2r - c1i * c2i,
c1i * c2r + c1r * c2i,
];
}
function mKron(...matrices: Array<Matrix>): Matrix {
if (matrices.length === 1) {
return matrices[0];
}
const [m1, m2, ...rest] = matrices;
const height1 = m1.length, width1 = m1[0].length;
const height2 = m2.length, width2 = m2[0].length;
const kronProd: Matrix = Array.from(
{ length: height1 * height2 },
() => Array(width1 * width2)
);
for (let m = 0; m < height1; m++) {
for (let n = 0; n < width1; n++) {
for (let p = 0; p < height2; p++) {
for (let q = 0; q < width2; q++) {
const newM = m * height2 + p;
const newN = n * width2 + q;
kronProd[newM][newN] = cMultiply(m1[m][n], m2[p][q]);
}
}
}
}
return mKron(kronProd, ...rest);
}
function mMultiply (...matrices: Array<Matrix>): Matrix {
const [first, second, ...rest] = matrices;
const height1 = first.length,
width1 = first[0].length;
const height2 = second.length,
width2 = second[0].length;
if (width1 !== height2) {
throw new Error("Matrix dimensions incorrect for multiplication.");
}
for (let r = 0; r < height1; r++) {
for (let c = 0; c < width2; c++) {
let val = complex(0);
for (let k = 0; k < width1; k++) {
val = cAdd(val, cMultiply(first[r][k], second[k][c]));
}
result[r][c] = val;
}
}
let product = result;
for (const m of rest) {
product = mMultiply(product, m);
}
return product;
}
QUANTUM SECURITY CAM_1
OH HI CRAIG IT'S DARREN. I HAVE SCOTT.
MODOK
QUANTUM SECURITY CAM_1
OH HI CRAIG IT'S DARREN. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
QUANTUM SECURITY CAM_1
OH HI CRAIG IT'S DARREN. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
QUANTUM SECURITY CAM_1
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
QUANTUM SECURITY CAM_1
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
const constant0 = () => 0
const constant1 = () => 1
const balancedX = (x) => x;
const balancedNotX = (x) => 1 - x;
const oracles = [constant0, constant1, balancedX, balancedNotX];
const oracle = oracles[Math.floor(Math.random() * oracles.length)];
const constant0 = () => 0
const constant1 = () => 1
const balancedX = (x) => x;
const balancedNotX = (x) => 1 - x;
const oracles = [constant0, constant1, balancedX, balancedNotX];
const oracle = oracles[Math.floor(Math.random() * oracles.length)];
const constant = oracle(0) === oracle(1);
const balanced = !constant;
Initial state with two qubits
Hadamard gate for two qubits
Apply Hadamard gate to get superposition
Black Box "Oracle" for the unknown function
Apply the Oracle to the superpositioned state
First Qubit only Hadamard gate
Apply the gate to the state
The second qubit contains redundant information
const constant0 = [[complex(1),complex(0),complex(0),complex(0)],[complex(0),complex(1),complex(0),complex(0)],[complex(0),complex(0),complex(1),complex(0)],[complex(0),complex(0),complex(0),complex(1)]];
const constant1 = [[complex(0),complex(1),complex(0),complex(0)],[complex(1),complex(0),complex(0),complex(0)],[complex(0),complex(0),complex(0),complex(1)],[complex(0),complex(0),complex(1),complex(0)]];
const balancedX = [[complex(1),complex(0),complex(0),complex(0)],[complex(0),complex(1),complex(0),complex(0)],[complex(0),complex(0),complex(0),complex(1)],[complex(0),complex(0),complex(1),complex(0)]];
const balancedNotX = [[complex(0),complex(0),complex(1),complex(0)],[complex(0),complex(0),complex(0),complex(1)],[complex(1),complex(0),complex(0),complex(0)],[complex(0),complex(1),complex(0),complex(0)]];
const oracles = [constant0, constant1, balancedX, balancedNotX];
const oracle = oracles[Math.floor(Math.random() * oracles.length)];
const zero = kZero();
const one = kOne();
const phi0 = mKron(kZero(), kOne());
const HkH = mKron(mHadamard(), mHadamard());
const phi1 = mMultiply(HkH, phi0);
const phi2 = mMultiply(oracle, phi1);
const HkI = mKron(mHadamard(), mIdentity());
const phi3 = mMultiply(HkI, phi2);
const result = measure(ignore(phi3, 1));
if (result === 0) {
console.log('Function is constant');
} else {
console.log('Function is balanced');
}
const oracle = ORACLES[Math.floor(Math.random() * oracles.length)];
function isConstant (f, n) {
const first = f(0);
for (let i = 1; i < 2 ** n; i++) {
if (f(i) !== first) {
return false;
}
}
return true;
}
const constant = isConstant(oracle, 3);
const balanced = !constant;
Initial state with three qubits
Hadamard gate for three qubits
Apply Hadamard gate to get superposition
Black Box "Oracle" for the unknown function
Size will increase exponentially with number of qubits
Apply the Oracle to the superpositioned state
First N-1 Qubits Hadamard gate
Apply the gate to the state
The second qubit contains redundant information
const oracle = [
// ...
];
let x = kZero();
for (let i = 1; i < n; i++) {
x = mKron(x, kZero());
}
let y = kOne();
const phi0 = mKron(x, y);
const Hn = mKron(...Array(n).fill(mHadamard()));
const HnH = mKron(Hn, mHadamard());
const phi1 = mMultiply(HnH, phi0);
const phi2 = mMultiply(oracle, phi1);
const HnI = mKron(Hn, mIdentity());
const phi3 = mMultiply(HnI, phi2);
const outcome = measure(ignore(phi3, 1));
if (outcome === 0) {
console.log("Function is constant");
} else {
console.log("Function is balanced");
}
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
DEUTSCH-JOSZA
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
DEUTSCH-JOSZA
THAT WORKED. THE FIRST LOCK OPENED! 🐜
Scott Lang
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
DEUTSCH-JOSZA
THAT WORKED. THE FIRST LOCK OPENED! 🐜
Scott Lang
Quantum Search Algorithm
const N = 8;
const marked = 5;
const result = [...Array(N).keys()].find(x => x === marked);
console.log(result);
Initial state with two qubits
Hadamard gate for two qubits
Apply Hadamard gate to get superposition
Black Box "Oracle" for the search function
Apply the Oracle to the superpositioned state
Fancy operator made up of multiple gates
Apply diffusion
times
const N = Math.pow(2, n);
let state = kZero();
for (let i = 1; i < n; i++) {
state = mKron(state, kZero());
}
let Hn = mHadamard();
for (let i = 1; i < n; i++) {
Hn = mKron(Hn, mHadamard());
}
state = mMultiply(Hn, state);
const ones = Array.from({ length: N }, () => Array.from({ length: N }, () => complex(1 / N)));
const I = mIdentity(n);
const D = Array.from({ length: N }, (_, r) => Array.from({ length: N }, (_, c) => {
const [onesReal] = ones[r][c];
const [identityReal] = I[r][c];
return complex(2 * onesReal - identityReal, 0);
}));
const iterations = Math.max(Math.floor((Math.PI / 4) * Math.sqrt(N)), 1);
for (let i = 0; i < iterations; i++) {
state = mMultiply(oracle, state);
state = mMultiply(D, state);
}
console.log(measure(state));
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
GROVER'S
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
GROVER'S
NICE! The second lock is open!
Cassie Lang
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
GROVER'S
NICE! The second lock is open!
Cassie Lang
let n = 391;
const factors = [];
for (let i = 2; i < n; i++) {
while (n % i === 0) {
factors.push(i);
n = n / i;
}
}
if (n > 1) {
factors.push(n);
}
console.log(factors);
Not web scale
let a;
do {
a = Math.floor(Math.random() * (N - 2)) + 2;
} while (gcd(a, N) !== 1);
console.log(`Chosen a = ${a}`);
const n = Math.ceil(Math.log2(N));
const m = Math.ceil(Math.log2(N));
let input = kZero();
for (let i = 1; i < n; i++) input = mKron(input, kZero());
let output = kZero();
for (let i = 1; i < m; i++) output = mKron(output, kZero());
let phi0 = mKron(input, output);
const Hn = Array.from({ length: n }, () => mHadamard());
const HnKron = mKron(...Hn, mIdentity(m));
let phi1 = mMultiply(HnKron, phi0);
const U_f = modExpMatrix(a, N, n);
const UfFull = mKron(U_f, mIdentity(m));
let phi2 = mMultiply(UfFull, phi1);
const QFTn = qft(n);
const QFTFull = mKron(QFTn, mIdentity(m));
let phi3 = mMultiply(QFTFull, phi2);
const measured = measure(ignore(phi3, m));
console.log(`Estimate of period fraction: ${measured}`);
let r = 1;
while (modExp(a, r, N) !== 1) r++;
console.log("Estimated period r =", r);
if (r % 2 === 0) {
const factor1 = gcd(modExp(a, r / 2, N) - 1, N);
const factor2 = gcd(modExp(a, r / 2, N) + 1, N);
console.log(`Potential factors: ${factor1}, ${factor2}`);
} else {
console.log("Odd period found; retry with another a");
}
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
SHOR'S
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
SHOR'S
WHAT! HOW ARE YOU DOING THIS!
MODOK
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
SHOR'S
WHAT! HOW ARE YOU DOING THIS!
MODOK
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
I'M OUT! THANKS CRAIG! 🐜
Scott Lang
OH HI CRAIG IT'S DARREN/MODOK. I HAVE SCOTT.
MODOK
HE'S NEVER GETTING OUT OF HERE.
MODOK
Craig! It's Cassie, Scott's daughter!
Cassie Lang
We've figured out how to open dad's cell! You need to run some Quantum Algorithms!
Cassie Lang
It's Deutsch-Josza, Grover, Shor, in that order! But we don't know the inputs!?
Cassie Lang
I'M OUT! THANKS CRAIG! 🐜
Scott Lang