Interview Query

Dice Rolls From Continuous Uniform

Start Timer

0:00:00

Upvote
7
Downvote
Save question
Mark as completed
View comments (7)
Next question

You are given a function that generates a floating-point number between 0 and 1 from a continuous uniform distribution.

Write a function dice_rolls that takes the continuous random generator and simulates a dice roll (return a number between 1 and 6, with all numbers having a uniform distribution).

Example:

Output:

dice_roll(continuous_random_generator) -> 1
dice_roll(continuous_random_generator) -> 2
dice_roll(continuous_random_generator) -> 6
#and so on ...
.
.
.
.
.


Comments

Loading comments