Given a function Rand01Uniform() which generates a random integer number from [0,1] with a uniform distribution, write a function Rand06Uniform() which generates a random integer number from [0,6] with a uniform distribution.
phone interview May 2017

@eleHaj
Flip Rand01Uniform 3 times, and associate each result as follows:
000: 0
001: 1
010: 2
011: 3
100: 4
101: 5
110: 6
111: reflip# R = Rand01Uniform def Rand06Uniform(): while True: roll = 4 * R() + 2 * R() + R() if roll < 7: return roll

public static int coinAndDiceRandom() { int num = 1; Random random = new Random(); while(!(num>=0 && num<=6)) { int coin = random.nextInt( 2 ); // value [0,1] num = coin*1; coin = random.nextInt(2); num = num + coin*2; coin = random.nextInt(2); num = num + coin*4; System.out.println( "Dice is " + num ); } return num; }