How is the conditional expectation calculated? This is a question from "A first look at rigorous probability theory"

Let $\Omega=\{1,2,3\}$, with $\mathbf{P}\{1\} = \mathbf{P}\{2\}=\mathbf{P}\{3\} =1/3$.  Define random variables $X$ and $Y$ by $Y(\omega) = \omega$, and $X(1) = X(2) = 5$ and $X(3) = 6$. Let $Z=\mathbf{E}(Y|X)$.
(a). Describe $\sigma(X)$ precisely.
(b) Describe (with proof) $Z(\omega)$ for each $\omega\in \Omega$.

I know part a) that $\sigma(X)=\{\emptyset, \Omega, \{1,2\}, \{3\}\}$.
My question is, how to answer part b?
The definition from the book seems not helping at all.

$\mathbf{E}(Y|X)$ is a conditional expectation of $Y$ given $X$ if it is a $\sigma(X)$-measurable random variable and, for any Borel $S\subseteq \mathbf{R}$, we have $$\mathbf{E(\mathbf{E(Y|X)\mathbf{1}_{X\in S}})} = \mathbf{E}(Y\mathbf{1}_{X\in S})$$

 A: First, recall that the collection of all sets of the form $\{X \in S\}$, with $S$ Borel, is precisely $\sigma(X)$.
Hence, we must make $Z$ so that 
$$E(Z)=E(Y) = 2 \ ; \ E(Z1_{\{1,2\}}) = E(Y1_{\{1,2\}}) =  1\ ; \ E(Z1_{\{3\}}) = E(Y1_{\{3\}}) = 1.$$
Moreover, since $Z$ needs to be $\sigma(X)$-measurable, we must define $Z$ so that it is constant on the atoms of $\sigma(X)$, which are $\{1,2\}$ and $\{3\}$. Thus, in addition to the above constraints we must have
$$Z(1) = Z(2).$$
Now it's just a matter of solving for $Z(1)$, $Z(2)$, and $Z(3)$. 
First, $Z(3) = 3$ is immediate from $E(Z1_{\{3\}}) = E(Y1_{\{3\}}) = 1$.
Next,
$$2=E(Z) = 1/3(Z(1) + Z(2) + Z(3)) = 1/3(2Z(1) + 3)$$
implies $Z(1)=Z(2)=3/2$.
A: It is known that $E(Y|X)$ can be expressed as $f(X)$ for some function $f:\{5,6\} \to \mathbb R$. [ Here {5,6} is the range of X]. Th defining equations for $E(Y|X)$ are equivalent to two equations: $EI_{\{5\}} f(X)=EI_{\{5\} Y}$ and $EI_{\{6\}} f(X)=EI_{\{6\} Y}$ since the defining equation for other Borel sets will hold automatically. Since X takes the value 5 at 1 and 2 and the value 6 at 3 the equations become $f(5)=3$ and $f(6)=1$. Hence $E(Y|X)=f(X)=3/2$ when X=5 and 3 when X=6.
