[Solution] rand5 | Two Sigma Interview Question
This problem was asked by Two Sigma.
Using a function
rand7() that returns an integer from
7 (inclusive) with uniform probability, implement a function
rand5() that returns an integer from
Idea behind the solution
Similar to the fair coin problem, we just need to use the function
rand7() until we get something between
5 since we were told in advance that
rand7() is already supposed to be unbiased.
Please check the main.js snippet for the solution.
This solution originally posted at: Github by @Murillo2380