Here is another way to explain the exact same solution.

In full generality, what we need to find is a function $\displaystyle p:\mathbb{R}\to[0,1]$ that will describe our way to answer: if we are given the number $\displaystyle \alpha\in\mathbb{R}$, then we answer "It is Y (the larger one)" with probability $\displaystyle p(\alpha)$ and "It is X (the smaller one)" with probability $\displaystyle 1-p(\alpha)$. Note that this covers in particular the case of a deterministic answer ($\displaystyle p(\alpha)\in\{0,1\}$), even if this is not a good choice.

Suppose we are given the number $\displaystyle Q$, and that our answer (based on the above strategy) is $\displaystyle Z$, which is either 1 if we say that $\displaystyle Q$ is Y, or 0 is we say it is X. Then the probability that our guess was correct is:

$\displaystyle P(Q=Y\mbox{ and }Z=1)+P(Q=X\mbox{ and }Z=0)=\frac{1}{2}p(Y)+\frac{1}{2}(1-p(X))$ $\displaystyle =\frac{1}{2}+\frac{1}{2}(p(Y)-p(X))$.

As we can see, this is larger than $\displaystyle \frac{1}{2}$ if and only if $\displaystyle p(Y)>p(X)$. However, we don't know what $\displaystyle X$ and $\displaystyle Y$ are when we choose the function $\displaystyle p(\cdot)$. Therefore we have to choose a function such that $\displaystyle p(y)>p(x)$ for *all* real numbers $\displaystyle y>x$. In other words, $\displaystyle p$ must be strictly increasing from $\displaystyle \mathbb{R}$ to $\displaystyle [0,1]$. A possible choice of the function $\displaystyle p(\cdot)$ was given by TheOdds in his last post.