We can implement this encoding in two steps.

First, we use phase flip encoding on qubits with indices $0, 3, 6$ to convert $\alpha \ket{000} + \beta \ket{100}$ into $\alpha \ket{+++} + \beta \ket{---}$.
After this, the state of the system will be 

$$\alpha \ket{+00} \otimes \ket{+00} \otimes \ket{+00} + \beta \ket{-00} \otimes \ket{-00} \otimes \ket{-00}$$

Then, we use bit flip encoding on each triplet of qubits $0 \ldots 2, 3 \ldots 5, 6 \ldots 8$ to convert each $\ket{+00}$ into $\frac1{\sqrt2} (\ket{000} + \ket{111})$ and each $\ket{-00}$ into $\frac1{\sqrt2} (\ket{000} - \ket{111})$. After this, the nine-qubit system will be exactly in the state we're looking for.

@[solution]({
    "id": "qec_shor__shor_encode_solution",
    "codePath": "Solution.qs"
})
