Skip to content

Instantly share code, notes, and snippets.

@hleumas
Last active September 11, 2017 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hleumas/98e40ac13dcfc0c56d76be426182944a to your computer and use it in GitHub Desktop.
Save hleumas/98e40ac13dcfc0c56d76be426182944a to your computer and use it in GitHub Desktop.

Dice

Solution to this problem: https://twitter.com/nntaleb/status/907204053079400448

Solution

The dice will be rolled no more than 3 times. Smallest even number is 2 and 2x3=6, which is the desired sum.

Now, the problem statement says that we roll the dice only until we get the sum of 6 or more. Yet, nothing would change, if we rolled the dice exactly for 3 times, but ignored all rolls after we reach 6.

Now, naive solution would be to generate all triplets from numbers 2, 4, 6 and determine how many of them achieved sum >=6 after first, second, or third item. It's the very same thing Nassim Nicholas Taleb has done here: https://twitter.com/nntaleb/status/907211482743668737

However, that would be wrong. There is a subtle catch hidden. Remember, we ignore all rolls after we reach 6. That means, after we reach 6, the limitation for even numbers doesn't apply anymore. E.g. (6, 3, 3) is correct tuple, while (2, 2, 3) is not.

Let's count the tuples correctly:

Tuples with 1 dice throw

Anything begining with 6. There are 6x6=36 such tuples.

Tuples with 2 dice throws

(2, 4, x), (2, 6, x), (4, 2, x), (4, 4, x), (4, 6, x) where x is 1-6. There are 5x6=30 such tuples.

Tuples with 3 dice throws

(2, 2, 2), (2, 2, 4), (2, 2, 6). There are only 3 such tuples.

Average number of throws

(1x36 + 2x30 + 3x3) / (36 + 30 + 3) = 35/23 ~ 1.52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment