Teaching Kids Programming – Probability of Rolling a Dice: Strictly Increasing Order One After Another


Teaching Kids Programming: Videos on Data Structures and Algorithms

You are given a dice, rolling 3 times one after another. what is the probability of obtaining numbers in strictly increasing order?

Probability of Rolling a Dice – Strictly Increasing Order using Math

First, we compute the probability of rolling 3 unique numbers one after another.

The first time, we have 100% probability, and the second time, it is 5 over 6, and the third one is 4 over 6. Thus:

Rolling a 3 unique digit has probability of tex_cc7cb0118b056cf53e79c7adc0bfc0cd Teaching Kids Programming - Probability of Rolling a Dice: Strictly Increasing Order One After Another algorithms brute force math programming languages teaching kids programming youtube video

For each 3 digit, there are 6 permutations (3*2*1), and only 1 of them is strictly increasing, thus:

Probability of Rolling a Dice – Strictly Increasing Order is tex_ef7f75b9bb50080827133f73fca08ae8 Teaching Kids Programming - Probability of Rolling a Dice: Strictly Increasing Order One After Another algorithms brute force math programming languages teaching kids programming youtube video

Probability of Rolling a Dice – Strictly Increasing Order using Bruteforce/Simulation

We can bruteforce all possibilities of rolling a dice 3 times, and then count those with strictly increasing order:

1
2
3
4
5
6
7
8
9
cnt = 0
for first in range(1, 7):
    for second in range(1, 7):
        for third in range(1, 7):
            if first < second < third:
                cnt += 1
total = 6*6*6
print(cnt/total)
# print(1*(5/6)*(4/6)/6)
cnt = 0
for first in range(1, 7):
    for second in range(1, 7):
        for third in range(1, 7):
            if first < second < third:
                cnt += 1
total = 6*6*6
print(cnt/total)
# print(1*(5/6)*(4/6)/6)

Time and space complexity is O(1) constant as the problem scope is fixed. See also: Teaching Kids Programming – Probability of Two Sixes in a Row when Rolling a Dice Three Times (One After Another)

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
411 words
Last Post: Teaching Kids Programming - Probability of Two Sixes in a Row when Rolling a Dice Three Times (One After Another)
Next Post: Teaching Kids Programming - How to Draw a Star using Turtle Graphics? (Math, Shapes, Geometry)

The Permanent URL is: Teaching Kids Programming – Probability of Rolling a Dice: Strictly Increasing Order One After Another

Leave a Reply