Properly pick out an exercise based on weights

Summary:
This commit fixes a bug that would cause certain exercises to not show
up some of the time.

The indices of the problems are pushed into `typeIndex` a number of
times equal to their weights. The problem was that after an index was
selected it was picked directly from `problems`. This means that if an
index which is higher than the number of problems (but lower than the
sum of the weights) is picked, it will go out of bounds and the exercise
won't appear.

Test Plan:
* Load up an exercise (divisibility_tests for sure had this problem)
* Refresh a few times to see that the exercise always comes up

Reviewers: alex, alpert

Reviewed By: alpert

CC: alpert, brianmerlob

Differential Revision: http://phabricator.khanacademy.org/D6162