Proving that a function (involving the Cantor discontinuum ) is surjective. Exercise. Let $\mathcal{D} = \{2\sum_{i=1}^{\infty} x_i3^{-i} : \forall i \in \Bbb N, x_i \in \{0,1\}\}$ be the Cantor discontinuum. Now, consider the function
\begin{equation*}
g : \mathcal{D} \rightarrow [0,1] \quad \text{ s.t. } \quad g\left(2\sum_{i=1}^{\infty} x_i3^{-i}\right) = \sum_{i=1}^{\infty} x_i2^{-i}.
\end{equation*}
Prove that $g$ is a surjective function.
My attempt. We want to prove that $g$ is surjective, i.e., that
\begin{equation*}
 \forall x \in [0,1], \exists y \in \mathcal{D} \hspace{.15cm} | \hspace{.15cm} g(y) = x
\end{equation*}
Let $y \in \mathcal{D}$. Then, we might assume that $y = 2\sum_{i=1}^{\infty}x_i3^{-i}$, where $x_i \in \{0,1\}$. Besides this, we also see the following:
\begin{equation*}
 g(y) = \sum_{i=1}^{\infty} x_i2^{-i} = \frac{1}{2}\left(2\sum_{i=1}^{\infty}x_i3^{-i}\left(\frac{2}{3}\right)^{-i}\right) = \frac{1}{2}y\sum_{i=1}^{\infty}\left(\frac{2}{3}\right)^{-i}
\end{equation*}
and thus,
\begin{equation*}
 g(y) = x \Leftrightarrow \frac{y}{2}\sum_{i=1}^{\infty}\left(\frac{2}{3}\right)^{-i} = x \Leftrightarrow y = 2\sum_{i=1}^{\infty} (x2^i)3^{-i}.
\end{equation*}
And I believe this should be enough to prove the surjectivity. BUT $y$ doesn't seem to be a member of $\mathcal{D}$ since we can't say that $x_i = x2^{i} \in \{0,1\}$ (If $i$ is any integer and $x$ is any number on the unitary interval, then this obviously isn't true). This leads me to conclude that my resolution might not be right at all, and this is why I am posting this.
Thanks for any help in advance.

I think your approach is too complicated. You should know that each sequence $(x_i)$ with $x_i \in \{0,1\}$ determines a unique point $\phi((x_i)) = 2\sum_{i=1}^\infty x_i3^{-i} \in \mathcal{D}$. And should also know that each $x \in [0,1]$ has a dyadic representation $x = \sum_{i=1}^\infty x_i2^{-i}$ with $x_i \in \{0,1\}$. This is not unique, e.g. we have $1/2 =  \sum_{i=1}^\infty x_i2^{-i}$ with $x_1 = 1$ and $x_i = 0$ for $i > 1$ and also $1/2 =  \sum_{i=1}^\infty x_i2^{-i}$ with $x_1 = 0$ and $x_i = 1$ for $i > 1$.
But despite of non-uniqueness this shows that your function $g$ is surjective.
