Problem 53850. Backgammon #4 - Dice Probabilities

Previous problems in this series have looked at how a backgammon board might be represented, and board positions manipulated and displayed. In this problem we take a break from looking at backgammon boards, and turn our attention to dice throws.
Backgammon is played with two standard six-sided dice.
Sometimes it is necessary to understand the chances of obtaining a particular dice throw, for example when trying to determine the risks of leaving a blot (a single stone), or when considering whether to offer or accept a double.
In this problem you are given a 'required' throw from two dice as an input vector - for example if you need to throw a 3 and a 6, the input vector will be:
[3,6]
You have to return the probablility (between 0 and 1) of obtaining such a throw.
Sometimes you only care about the value of one of the dice, so in that case the value of the other dice will be set to zero - for example if you need to throw at least one 2 on the two dice, and don't care what the other dice is, the input vector will be one of:
[2,0], [0,2]
Again you have to return the probablility (between 0 and 1) of obtaining such a throw.
If the input is not a valid throw, such as:
[0,0], [4,8], [-2,5]
you should return NaN.
Regexp cheats and other cheats are not appreciated and will be blocked if you use them.

Solution Stats

27.54% Correct | 72.46% Incorrect
Last Solution submitted on Apr 19, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers12

Suggested Problems

More from this Author17

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!