DEV Community

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

Posted on

3 1

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:

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly β€” using the tools and languages you already love!

Learn More

Top comments (1)

Collapse
 
abhilearnstocode profile image
Abhii β€’

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

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay