DEV Community

Cover image for How I created biased dice.
Sajal Gupta
Sajal Gupta

Posted on

How I created biased dice.

Can you create biased dice where the probability of getting an even number is more?

The question was asked in MakeMyTrip interview.

A dice has 6 states : {1, 2, 3, 4, 5, 6} and the problem is P{2, 4, 6} > P{1, 3, 5}.

Can you create a mathematical function to solve this problem without hampering the dice randomness?

Follow up the below video lineups to find the solution or comment down your approach how you will solve it

int function DiceMoves() {

    // your code here

    return diceState;

}
Enter fullscreen mode Exit fullscreen mode

Watch my videos on the same:



Please like share and subscribe if love my videos.

My solution code at:

Discussion (1)

Collapse
abhilearnstocode profile image
Abhii

You got a new subscriber!!!
Loved the content 🤩