No need for guesses! For a continuous random variable X with range (a,b) with density function f(x), define the cumulative probability function F(x) = \int_a^x f(t) dt,where \int_a^x stands for "integral from t=a to t=x". Then, the random variable U defined by U = F(X) / F(b) is uniformly distributed with range (0,1).
For discrete random distributions, replace integrals by sums in the definition of F(x). The algorithm that Andrey described for you essentially solves F(X) = U, where U is obtained from a uniform random number generator. The solution X is the result that you sought.
To supplement the mathematical argument that I stated, you can easily run a Monte-Carlo simulation, generating a few million random numbers with your distribution. Count the numbers of times that 1, 2 and 3 occur in the sequence, and divide by the number of random numbers generated. The resulting fractions should be close to 1/2, 1/3 and 1/6.