Solutions to other tests:
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  

Mathematics for the Digital Age
and
Programming in Python


>>> Second Edition

Test 13

1.
55 ⁄ 136

There are 55 pages with a 1: 1, 11, 21, ..., 91; 12, 13, ... 19; 100 - 136,
that is, 10 + 8 + 37 = 55.
2.
1 ⁄ 2

In each experiment there are either two or more heads or two or more tails.  The probability of getting two or more heads is the same as the probability of getting two or more tails.
3.
(3 + 4 + 5 + 7 + 8) ⁄ 36 = 27 ⁄ 36 = 3 ⁄ 4
4.
13 ⁄ 32

The total possible number of outcomes is 25 = 32.  There are 13 favorable outcomes:
ooooo oooox oooxo ooxoo oxooo xoooo
ooxox oxoox xooox oxoxo xooxo xoxoo
xoxox
(The numbers of favorable outcomes for 1, 2, 3, ... tosses are consecutive Fibonacci numbers, starting from 2.)
5.
22 ⁄ 425

4 * choose(13, 3) ⁄ choose(52, 3) =
(4 * 13 * 12 * 11) ⁄ (52 * 51 * 50) =
(2 * 11) ⁄ (17 * 25)
6.
17 ⁄ 50

There are 100 ways to chose the ordered pair.  If the first number is 0, 3, 6, or 9, there are 4 ways to choose the second number.  If the forst number is 1, 2, 4, 5, 7, or 8, there are 3 ways to choose the second number.  The total number of favorable choices is 4 * 4 + 6  3 = 34.  The probability that the sum is divisible by 3 is 34 ⁄ 100 = 17 ⁄ 50.
7.
1 ⁄ 10

There are choose(20, 2) = 20 * 19 ⁄ 2 = 190 ways to choose a pair of seats for Ana and Aaron; 19 of these pairs are adjacent seats.
8.
192 ⁄ 54145 ≈ 0.003546

There are 9 ways to choose the rank of the top card, 4 ways to choose a suit for each card.  The probability is 9 * 45 ⁄ choose(52, 5) = 192 ⁄ 54145
9.
1 ⁄ 90

There are choose(6, 2) = 15 ways to choose the first pair and choose(6, 2) = 6 ways to choose the second pair (and 1 way to choose the remaining pair).  The probability is 1 ⁄ (15 * 6).
10.
1 ⁄ 79

For any two cards in the Set deck there is a unique third card that makes a set with them.  The probability is (81 * 80) ⁄ (81 * 80 * 79).
11.
11 ⁄ 18

Let's consider ordered pairs of dominoes.  If the first domino is a double, it fits with 6 other dominoes and does not fit with the remainig 21 — this makes 7 * 21 pairs that do not fit.  If the first domino is not a double, it fits with 12 other dominoes, 6 on each end, and does not fit with the remaining 15 — this makes 21 * 15 more pairs that do not fit.  The total number of ordered pairs that do not fit is 7 * 21 + 21 * 15 = 21 * 22, out of 28 * 27 total possible pairs.  The probability that two random dominoes do not fit together is (21 * 22) ⁄ (28 * 27) = 11 ⁄ 18.
12.
9 ⁄ 64

The total number of three-step walks is 43 = 64.  9 of them end one step to the right:
RLR RRL RUD RDU UDR URD DUR DRU LRR
13.
37 ⁄ 64

1 − (1 − 1 ⁄ 4)3 = 37 ⁄ 64.
14.
choose(10, 3) p3 * (1−p)7 
15.
100% − (1.24+1.06+0.99)% = 0.9671.
16.
23 ⁄ 57

1 − choose(17, 3) ⁄ choose(20, 3) = 23 ⁄ 57
17.
7 ⁄ 8

Bill wins one dollar unless he loses three games in a row.  The probability that he does lose three games in a row is (1 ⁄ 2)3 = 1 ⁄ 8.  The probability that he wins one is 1 − 1 ⁄ 8 = 7 ⁄ 8.
18.
19 ⁄ 125

There are 19 combinations of the first two addends such that their sum falls in the range from −2 to 2 (and thus can be cancelled by the third addend): (−2, 0), (−2, 1), (−2, 2), (−1, −1), (−1, 0), etc.  The total number of possible combinations is 53 = 125.
19.
1 ⁄ 3

Each of the numbers 1, 2, 3 can appear in any element of lst with equal probability and each can be chosen with equal probability.
20.
0

experiment recursively calls itself until it returns 1, which then is passed all the way up and returned by the original call.  The process is limited only by the allowed depth of recursion in Python, about 1000.  There may be a (1 ⁄ 2)1000 chance that experiment will crash with the "depth of recursion exceeded" error, that is, it "never" happens.

21.
def all5ScoreProbability(lst): pAll = 1 for p in lst: pAll *= p return pAll
22.
(a)
    1 − (1 − 1 ⁄ 8)3) = 169 ⁄ 512
(b)
    1 ⁄ 2

Each of the first two questions can cut the set of candidates by half, leaving only two candidates after two questions.  For example, the first question might be "Is your number greater than 4?" The probability of guessing the number correctly from the remaining two candidates with the third question is 1 ⁄ 2.
23.
def randint(a, b): return a + int((b - a + 1) * random())
24.
from random import random N = 10000 count = 0 for k in range(N): x = random() y = random() if x*x + y*y <= 1: count += 1 print(4 * count / N)
25.
(a)
def generateNim(): return [randint(4, 7), randint(4, 7), randint(4, 7), randint(4, 7)] (b)

3 ⁄ 4

The numbers from 4 to 7 use three binary digits, with the leftmost digit always set to 1.  Therefore, the leftmost column always has even parity.  The remaining two columns can have any combination of binary digits in each row, with equal probabilities.  Only one number out of four possible numbers for the fourth pile (the fourth row) will result in even parity in all the columns; the other three numbers will result in odd parity in at least one column.
26.
from random import random def choice(s): count = 1 luckyNumber = None for x in s: if random() < 1 / count: luckyNumber = x count += 1 return luckyNumber



Copyright © 2010 by Skylight Publishing