<jupyter_start><jupyter_text>[Superdense Coding Code used from IBM's Qiskit Tutorials](https://qiskit.org/textbook/ch-algorithms/superdense-coding.html) Code adapted for Cirq<jupyter_code>import unittest

import cirq
import random
import numpy as np

import hypothesis.strategies as st
from hypothesis import given, settings
def create_bell_pair(qubits):
    qc = cirq.Circuit() 
    qc.append(cirq.H(qubits[1]))
    qc.append(cirq.CNOT(qubits[1],qubits[0]))
    return qc
def encode_message(qc, qubit, msg):
    if len(msg) != 2 or not set([0,1]).issubset({0,1}):
        raise ValueError(f"message '{msg}' is invalid")
    if msg[1] == "1":
        qc.append(cirq.X(qubit))
    if msg[0] == "1":
        qc.append(cirq.Z(qubit))
    return qc
def decode_message(qc, qubits):
    qc.append(cirq.CNOT(qubits[1],qubits[0]))
    qc.append(cirq.H(qubits[1]))
    return qc
qubits = cirq.LineQubit.range(2)
qc = create_bell_pair(qubits)

message = '11'    
    
qc = encode_message(qc, qubits[1], message)

qc = decode_message(qc, qubits)

qc.append(cirq.measure(*qubits, key='m'))

print(qc)

simulator = cirq.Simulator()
results = simulator.run(qc , repetitions =1)
readings = np.array2string(results.measurements['m'][0], separator='')[1:-1][::-1]
print(readings)<jupyter_output>0: ───────X───X───────M('m')───
          │   │       │
1: ───H───@───@───H───M────────
00
{'fraction_non_alphanumeric': 0.18567251461988304, 'fraction_numerical': 0.021198830409356724, 'mean_word_length': 4.41106719367589, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '615131', 'license': 'MIT', 'n_tokens_mistral': 570, 'n_tokens_neox': 534, 'n_words': 103, 'path': 'Superdense Coding/Cirq  Code/Superdense Coding Cirq.ipynb', 'repo_name': 'Lilgabz/Quantum-Algorithm-Implementations', 'size': '1368'}