Teaching Kids Programming – Probability of Two Sixes in a Row when Rolling a Dice Three Times (One After Another)


Teaching Kids Programming: Videos on Data Structures and Algorithms

Rolling a dice three times one after another, what is the probability of having Two Sixes in a Row?

Rolling two sixes in a row can only be done in the following cases:

  1. First and Second Six (third one not six): tex_f34eb56c76b0278f2764bdda004e62b6 Teaching Kids Programming - Probability of Two Sixes in a Row when Rolling a Dice Three Times (One After Another) algorithms brute force math probability python teaching kids programming youtube video
  2. Second and Third Six (first one not six): tex_f34eb56c76b0278f2764bdda004e62b6 Teaching Kids Programming - Probability of Two Sixes in a Row when Rolling a Dice Three Times (One After Another) algorithms brute force math probability python teaching kids programming youtube video
  3. Three Sixes: the probability is tex_5eeebf0c579b5ae5911b1aae9cbb4421 Teaching Kids Programming - Probability of Two Sixes in a Row when Rolling a Dice Three Times (One After Another) algorithms brute force math probability python teaching kids programming youtube video

Adding these cases to desired probability: tex_0728410f638df08332b92faff192f01d Teaching Kids Programming - Probability of Two Sixes in a Row when Rolling a Dice Three Times (One After Another) algorithms brute force math probability python teaching kids programming youtube video

1
2
3
# 66? ==> (1/6)^2*(5/6)
# ?66 ==> (1/6)^2*(5/6)
# 666 ==> (1/6)^3
# 66? ==> (1/6)^2*(5/6)
# ?66 ==> (1/6)^2*(5/6)
# 666 ==> (1/6)^3

We can bruteforce since the total cases are 6*6*6 and then we count the cases when there are two consecutive sixes.

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

O(1) constant complexity for time and space since the input size is fixed to 3 dices (constant loops, 216). See also: Teaching Kids Programming – Probability of Rolling a Dice: Strictly Increasing Order One After Another

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
420 words
Last Post: Teaching Kids Programming - Find Three Consecutive Integers That Sum to a Given Number
Next Post: Teaching Kids Programming - Probability of Rolling a Dice: Strictly Increasing Order One After Another

The Permanent URL is: Teaching Kids Programming – Probability of Two Sixes in a Row when Rolling a Dice Three Times (One After Another)

Leave a Reply