এই বইটি এখনো বাংলা ভাষায় পাওয়া যায় না। সংস্করণ: English, Français।
Interviews I: Maths, Probability and Speed · ক্যারিয়ার
7Counting and Symmetry
Counting without listing: choosing the right objects to count, subtracting what you overcounted, reflecting paths, and noticing when a symmetry gives the answer with no counting at all. The later questions need a bijection or a group of rotations that you have to find for yourself.
Question 7.1 ★ QR, QT, Trader, Analyst • any • junior
Eight people sit around a round table, and two seatings count as the same if one is a rotation of the other. How many seatings are there? How many keep two particular people from sitting next to each other?
Answer
Answer to Question 7.1.
There are seatings, and keep the two apart.
Fix one person’s chair to remove the rotations, and then seat the other seven in order. For the second count, subtract the seatings with the two together. Glue them into a block: that leaves seven objects around the table, which gives arrangements, and the block has 2 internal orders. So .
Follow-up. What fraction is that? . Seen from one of the two, the other sits in one of seven chairs at random, and two of those are adjacent.
Question 7.2 ★ QR, QT, Trader, Analyst • any • junior
How many distinct arrangements are there of the letters of MISSISSIPPI? In how many of them are no two S’s next to each other?
Answer
Answer to Question 7.2.
There are arrangements, of which have no two S’s together.
There are 11 letters, with four I’s, four S’s and two P’s, so the multinomial coefficient gives .
For the second count, place the S’s last. The seven other letters can be arranged in ways. They leave 8 gaps, counting both ends, and the four S’s go into four different gaps, in ways. The product is , or of the total.
Classic wrong answer. Subtracting “arrangements with an SS block” from the total. Blocks overlap in many ways, and the gaps method avoids all of them.
Question 7.3 ★ QR, QT, Trader, QD • any • junior
You walk on a grid from the corner to the corner , with each step going one unit right or one unit up. How many paths are there? How many avoid the point ?
Answer
Answer to Question 7.3.
There are 252 paths, and 132 avoid the point.
A path is a string of five rights and five ups, so there are . Those through split into two independent parts, ways to reach it and ways to go on. So 120 pass through it, and avoid it.
Follow-up. How would you code it for many blocked points? Fill a table by dynamic programming: each cell holds the sum of the cells to its left and below, and zero if blocked.
Question 7.4 ★ QR, QT, Trader, Analyst • any • junior
In how many ways can you put 10 identical coins into 4 labelled boxes? In how many ways if no box may be empty?
Answer
Answer to Question 7.4.
There are 286 ways with empty boxes allowed, and 84 ways with none empty.
Use stars and bars. Line up the 10 coins and put 3 dividers among them. That is a choice of 3 places out of 13, so . If no box may be empty, put one coin in each first. That leaves 6 coins to share in any way: .
Classic wrong answer. , which is the answer for labelled coins. Identical coins make the outcome depend only on how many land in each box.
Question 7.5 ★ QR, QT, Trader, Analyst, Risk • any • junior
A committee of 4 is chosen from 6 men and 5 women. How many committees include at least one woman? Why does “choose one woman, and then any 3 of the other 10” give the wrong number?
Answer
Answer to Question 7.5.
There are 315 committees. The shortcut gives 600, because it counts a committee once for each woman in it.
Count the complement: of the committees, are all men, and .
The wrong method names one woman as “the” woman and then chooses the remaining three, giving . A committee with women is produced times, once for each of them. Adding up the number of women over all committees gives exactly 600.
Why it matters. Whenever a count looks too big, ask how many times each object is produced. That question finds most counting errors.
Question 7.6 ★ QR, QT, Trader • any • junior
You roll five fair dice and look only at which values came up, ignoring the order. How many different results are there? What is the probability of a full house, meaning three of one value and two of another? Why can you not divide by the first number to get it?
Answer
Answer to Question 7.6.
There are 252 different results, and the probability of a full house is .
A result ignoring order is a multiset of 5 values from 6, so stars and bars gives .
The results are not equally likely, so you cannot divide by 252. A full house, say 3, 3, 3, 5, 5, arises from ordered rolls, while 1, 2, 3, 4, 5 arises from 120 and five sixes from just one. So count ordered rolls: 6 choices for the triple, 5 for the pair, 10 orders, which is 300 out of .
Classic wrong answer. Dividing by 252 to get . Treating unordered results as equally likely is the most common error in this chapter’s topic.
Question 7.7 ★ QR, QT, Trader, Risk • any • junior
An urn holds 5 blue balls and 3 red ones. You draw them all, one at a time, without replacement. What is the probability that the last ball is red? And the second ball?
Answer
Answer to Question 7.7.
Both are .
Use symmetry. Every ordering of the eight balls is equally likely, so every position has the same chance of holding a given ball. Each of the 8 balls is equally likely to be last, and 3 of them are red. The same holds for the second position, and for any other.
Classic wrong answer. Conditioning through all the earlier draws. This works, but it takes a page, and the symmetry makes the order in which balls come out irrelevant. The first ball you see does change the conditional chance for the second, but before you see anything, each position has the same chance.
Question 7.8 ★ QR, QT, Trader, Analyst • any • junior
A cube of side 10 is painted on the outside and cut into 1 000 unit cubes. How many unit cubes have paint on exactly 3, 2, 1 and 0 faces? If you pick one unit cube at random, how many painted faces does it have on average?
Answer
Answer to Question 7.8.
There are 8 with three painted faces, 96 with two, 384 with one and 512 with none. On average a unit cube has painted faces.
The corners give the 8. Each of the 12 edges has inner cubes, which gives 96. Each of the 6 faces has interior squares, which gives 384. The inside is a block of . These add to 1 000, which is the check.
For the average, count painted faces from the outside: the big cube has 6 faces of 100 unit squares each, which makes 600 faces. Spread over 1 000 cubes that is .
Follow-up. And for a side of ? faces on average.
Question 7.9 ★ QR, QT, Trader, Analyst, Risk • any • junior
A lottery draws 6 numbers from 49, and your ticket holds 6 numbers. What is the probability that exactly 3 of your numbers match? And at least 3?
Answer
Answer to Question 7.9.
Exactly 3 has probability , or about 1 in 57, and at least 3 has probability , or about 1 in 54.
Count the draws by how they split between your 6 numbers and the other 43: the hypergeometric distribution. There are draws. Exactly 3 matches come from draws. Summing over 3, 4, 5 and 6 matches gives .
Classic wrong answer. Using a binomial with . Draws are made without replacement, so the matches are not independent. The binomial gives a value near , too high.
Question 7.10 ★★ QR, QT, Trader, QD • any • junior
How many of the numbers from 1 to 1 000 are divisible by none of 2, 3 and 5?
Answer
Answer to Question 7.10.
There are 266.
Use inclusion-exclusion. Count the multiples of each prime and subtract, then add back those subtracted twice, then remove those added back too often:
The middle terms are multiples of 6, 10 and 15, and the last term is multiples of 30.
A quick check is by density. A share of whole numbers avoid all three primes, and . The same pattern repeats every 30 numbers, with 8 survivors in each block.
Classic wrong answer. Multiplying with rounding at each step. It happens to be close, but a rounded product is not a count: inclusion-exclusion gives the exact number.
Follow-up. How would you code it for many primes? Sieve up to , or walk the subsets of primes with the sign of each subset. The subset walk is the better choice when is huge and is small.
Question 7.11 ★★ QR, QT, Trader, QD • any • junior
You throw 5 labelled balls into 3 labelled boxes, each ball choosing a box uniformly at random. What is the probability that no box is empty?
Answer
Answer to Question 7.11.
The probability is .
Use inclusion-exclusion over the empty boxes. There are assignments. Those missing a particular box number , and there are three boxes. Those missing two particular boxes number just 1, and there are three pairs. So the count of assignments with no empty box is
As a check, count by shapes. The box sizes are 3, 1, 1 or 2, 2, 1. There are of the first shape and of the second, and .
Classic wrong answer. Starting by placing one ball in each box and letting the rest go anywhere: , which is more than the total. Any ball could have been the “first” in its box, so each assignment is counted several times.
Follow-up. What else does this compute? It is the same as asking for the chance that a coupon collector with 3 coupons finishes within 5 draws.
Question 7.12 ★★ QR, QT, Trader, Risk • any • junior
Five letters are placed at random in five addressed envelopes, one in each. What is the probability that no letter is in its right envelope? That exactly two are? What does the first probability approach with many letters?
Answer
Answer to Question 7.12.
No letter correct has probability , exactly two correct has probability , and the first approaches .
A permutation with no fixed point is a derangement. By inclusion-exclusion,
The convergence is very fast. Even five letters are within of the limit.
For exactly two correct, choose which two, and derange the other three: .
Classic wrong answer. Thinking the chance of no match must grow or shrink strongly with more letters. There are more letters to match, but each has less chance of matching, and the two effects cancel: the expected number of matches is always one, and the number of matches tends to a Poisson with mean 1.
Follow-up. Is exactly four correct possible? No. If four letters are right, the fifth envelope is the only one left, and the letter must be right too.
Question 7.13 ★★ QR, QT, Trader • market maker, hedge fund • junior
In an election, candidate A receives 6 votes and candidate B receives 4. The votes are counted one by one, in a random order. What is the probability that A is strictly ahead throughout the count, from the first vote on?
Answer
Answer to Question 7.13.
The probability is .
This is the ballot theorem, and the proof uses reflection. Of the orders, count the bad ones, where the count is tied at some point. An order that starts with a B vote is bad for sure, since A has to catch up, which leaves a tie. There are such orders.
Now take an order that starts with A and has a tie. Swap A and B votes up to the first tie. This gives an order starting with B, and the swap can be undone. So bad orders starting with A also number 84. The good orders number , and .
Classic wrong answer. Treating it as “A has more votes, so is usually ahead” and giving a large number. A lead from the very first vote is a strong demand, and it fails whenever B leads early.
Follow-up. And with 60 votes against 40? The chance is the same formula: . Only the margin as a share of the votes matters, which tells you that the size of the count does not.
Question 7.14 ★★ QR, QT, Trader • hedge fund, market maker, bank • junior
Ten people queue in random order at a kiosk that sells $5 tickets and starts with an empty till. Five of them hold one $5 note and five hold one $10 note. What is the probability that the kiosk never lacks change? What if six hold $5 notes and four hold $10 notes?
Answer
Answer to Question 7.14.
With five of each, the probability is . With six $5 and four $10 notes, it is .
Write a $5 note as an up step and a $10 note as a down step. The till has enough change exactly when the walk never goes below 0. Use reflection on the bad orders: those that touch . Reflect the part of the walk up to the first touch of . It then starts from and ends at the same point, so bad orders match every path from to the end point. For five and five, such a path has six up steps and four down steps, so there are of them, against the total of . So 42 are good, which is the Catalan number , and .
The general result for fives and tens is . For six and four, : of the 210 orders.
Classic wrong answer. Assuming that with equal notes the chance is about one half. Having enough change at the very end is automatic, and it is the path before the end that fails.
Why it matters. Reflection is the tool behind pricing a barrier option in a binomial model: a price path that crosses a level is matched with a reflected one that ends elsewhere.
Question 7.15 ★★ QR, QT, Trader • any • junior
You flip 11 fair coins and I flip 10. What is the probability that you get strictly more heads than I do? Find it without any summation.
Answer
Answer to Question 7.15.
The probability is exactly .
Compare after the first ten flips of each. Let be your heads in the first 10 and mine. By symmetry, , say, and . You win if , or if and your last coin is heads. If , even a final head gives at most a tie, and a tie is not strictly more. So your chance is .
A neater version: you have either more heads than I have, or more tails, and never both, because your 11 flips exceed my 10. For a fair coin, heads and tails have the same role, so each has probability .
Classic wrong answer. Thinking the extra coin gives you more than half. It does give you the tie-break, but ties were counted against you to begin with, so the gain only just brings you to one half.
Follow-up. And with a biased coin? The symmetry fails. If heads is more likely than tails, then you win more than half the time, because the event “more heads” is favoured.
Question 7.16 ★★ QR, QT, Trader • hedge fund, market maker • junior
You deal a shuffled 52-card deck face up until the first ace appears. Is the next card more likely to be the ace of spades or the two of clubs? Find the probability of each.
Answer
Answer to Question 7.16.
They are equally likely: each has probability exactly .
Build the shuffled deck in two steps. Take out the card you care about, and shuffle the other 51. Now insert it at a random place, one of the 52 possible gaps.
For the two of clubs: it is “right after the first ace” for exactly one of the 52 gaps, whichever the other 51 cards look like. So its chance is .
For the ace of spades: use the same deal. The other 51 cards contain three aces, and the first of them is somewhere. If you insert the ace of spades right after it, it is the next card after the first ace. If you insert it earlier, it becomes the first ace itself, and it does not follow one. If you insert it later, it does not come next. So exactly one gap works, and again the chance is .
Classic wrong answer. Saying the ace of spades is less likely, because it might have already gone as the first ace, or more likely, because aces cluster. Both feelings are correct about something, but the insertion count settles it.
Why it matters. Building a random object one card at a time from a simpler one often avoids a heavy conditioning, and interviewers look for this kind of step.
Question 7.17 ★★ QR, QT, Trader • any • junior
A shuffled 52-card deck is dealt into four hands of 13 cards each. What is the probability that each hand holds exactly one ace?
Answer
Answer to Question 7.17.
The probability is .
Place the aces one by one, thinking of the deck as 52 slots in four hands. The first ace goes anywhere. The second must avoid the 12 other slots in its hand, so it has 39 good slots of the 51 left. The third has 26 good slots of the 50 left, and the fourth 13 of the 49 left.
The other route is by counting whole deals. The number of deals where each hand has an ace is , against deals in all. It reduces to the same fraction, with a good deal more cancelling.
Classic wrong answer. The independent answer, . This treats each ace as choosing a hand independently, and it misses the fact that a hand holding an ace has less room for the next.
Follow-up. Which method carries further? Placing special cards one by one works whenever the special cards are few. Counting deals is better when you must control many cards at once.
Question 7.18 ★★ QR, QT, Trader • any • junior
You roll three fair dice. In how many of the 216 outcomes is the sum 10, and in how many is it 11? Why must those be equal? Then find the number of outcomes with sum 14 for four dice, without listing them.
Answer
Answer to Question 7.18.
Both sums have 27 outcomes, and sum 14 on four dice has 146.
Listing unordered triples for 10 gives , , , , , , with orders, which is 27. They are equal by a symmetry of the die: replacing each face by is a bijection of outcomes that sends a sum to , and .
For four dice, use stars and bars with inclusion-exclusion. Writing , you need with . With no ceiling that has solutions. If one , take away 6 from it and count solutions of a sum to 4: , for each of 4 dice. Two cannot exceed at once, because . So .
Why it matters. Stars and bars with a ceiling is the same calculation as a discrete convolution, and the mirror symmetry halves the work whenever you compute a dice table by hand.
Question 7.19 ★★ QR, QT, Analyst, Risk • any • junior
Twelve people are split at random into three groups of four, and the groups have no labels. How many such splits exist? What is the probability that two particular people end up together?
Answer
Answer to Question 7.19.
There are splits, and the chance that the two end up together is .
For the number of splits, start with orderings, cut into three blocks of four, and divide out the orders inside each block and the orders of the blocks: . Alternatively, choose the 3 companions of a fixed person, then the 3 companions of the first person left over: .
The second part needs no counting at all. Stand with the first person. Their group has 3 other places, and by symmetry the second person is equally likely to be in any of the other 11 places. So the chance is . Counting confirms it: of the 5775 splits have both together.
Classic wrong answer. Giving because there are three groups. That would be right if each person chose a group independently, but your own group has only three places left, while the others have four each.
Follow-up. With labelled groups? The number of splits becomes , six times as many. The probability stays the same.
Question 7.20 ★★ QR, QT, Trader • hedge fund, bank • junior
A knockout tournament has 64 players and a random draw, with every match a fair coin flip. What is the probability that two particular players meet? If instead the better player always wins, what is the probability that the second-best player reaches the final?
Answer
Answer to Question 7.20.
The two players meet with probability . The second-best player reaches the final with probability .
For the first part, count matches rather than rounds. Exactly one player leaves in each match, so a 64-player tournament has 63 matches. There are pairs of players. By symmetry every pair is equally likely to be the pair in any given match, so each pair meets with probability , and in general .
For the second part, the second-best can lose only to the best. The two are in opposite halves of the draw exactly when the second-best reaches the final. Given the place of the best player, there are 63 other places, of which 32 lie in the other half. So the chance is .
Classic wrong answer. Working through the rounds, with a factor for each round that both must survive. That can be done and takes much longer. Linearity with the matches gives the answer in one line.
Why it matters. This is why the runner-up in a knockout is a poor estimate of the second-best: it is right just over half the time.
Question 7.21 ★★ QR, QT, Trader, QD • any • junior
Put 6 points on a circle and draw every chord between them, in positions where no three chords pass through one interior point. How many regions does the disc split into? Why is the pattern 1, 2, 4, 8, 16 a trap? How many regions come from 10 points?
Answer
Answer to Question 7.21.
Six points give 31 regions, not 32, and 10 points give 256.
The formula is . Start with the disc, one region. Draw the chords one at a time. A new chord adds one region for itself, and one more for each chord it crosses, because each crossing cuts one more existing region in two. So the number of regions is . There are chords, and each set of 4 points gives exactly one crossing, the crossing of its two diagonals. So there are crossings. For : . For : .
The formula gives for only because matches it for small . A polynomial of degree 4 cannot keep up with .
Classic wrong answer. Thirty-two, from the pattern. Interviewers ask this question to test whether a candidate will extrapolate from a few cases without a reason.
Follow-up. How can you check 31 with no formula? By Euler’s formula. With vertices and edges, the count of inner faces is , which is the same result.
Question 7.22 ★★ QR, QT, QD, Dev • any • junior
In how many ways can you make 100 cents from coins worth 1, 5, 10, 25 and 50 cents, with order ignored and any number of each?
Answer
Answer to Question 7.22.
There are 292 ways.
Use dynamic programming on the coins, one denomination at a time. Let be the ways to make amount with the coins used so far, starting from . For each coin , in turn, run upwards from and set . Going upwards lets a coin be reused, and going coin by coin counts each combination once only, regardless of order. This is the same as reading a coefficient in the generating function .
By hand, work over the numbers of large coins. With no 50 and no 25, for instance, choosing dimes leaves choices of nickels, and pennies fill the rest, which gives 121 ways for that case. Adding all the cases gives 292. An exhaustive loop over 50s, 25s, 10s and 5s, with pennies making up the rest, gives the same number.
Classic wrong answer. Looping amounts first and coins inside. That counts and as different, which counts orderings instead of combinations.
Follow-up. And the number of ways counting order? Swap the two loops. It grows enormous, because most of the sequences use many pennies.
Question 7.23 ★★ QR, QT, Trader • any • junior
How many solutions in whole numbers does have when each of must lie between 0 and 15?
Answer
Answer to Question 7.23.
There are 136 solutions.
With no ceiling, stars and bars gives . Now subtract the solutions in which a variable exceeds 15. If , put . Then , which has solutions. There are three such cases, and two variables cannot both be at least 16, since their sum would exceed 30. So inclusion-exclusion stops there: .
A check by geometry: the solutions form a triangular slice of a cube, and with a ceiling of half the total, the slice is the central triangle formed by the three midpoints. It has about a quarter of the unrestricted triangle’s area, and , a little more because of the boundary points.
Why it matters. Ceilings appear whenever capacity limits a split. This is the standard way to treat them, and it stops after one or two terms when the ceiling is large.
Question 7.24 ★★ QR, QT, Trader • hedge fund, market maker • junior
You shuffle a 52-card deck. What is the probability that all four aces come before any king? What if you also require all four queens to come after the kings?
Answer
Answer to Question 7.24.
The first is , and the second is .
Ignore all the other cards. Only the relative order of the 8 aces and kings matters, and every way of placing those is equally likely. Of the patterns of A and K, exactly one has all the A’s first. The other 44 cards are irrelevant.
For twelve cards with the order aces, kings, queens, look at the patterns of three letters: there are of them, and one is right.
Classic wrong answer. Multiplying conditional chances for each ace, such as for the first, then trying to track the deck. Removing irrelevant cards is the whole point.
Why it matters. This kind of reduction, where only the relative order of a few events matters, applies to any question of which event happens first among exchangeable times, such as which order fills first in a random arrival sequence.
Question 7.25 ★★ QR, QT, Trader, DS • any • junior
You and I each flip a fair coin 10 times. What is the probability that we get the same number of heads? Find a closed form with one binomial coefficient.
Answer
Answer to Question 7.25.
The probability is .
The direct sum is . The neat way sees the equal-heads event as a statement about 20 flips. Change the meaning of my flips by swapping heads with tails, which leaves them fair. Then “your heads equals my heads” becomes “your heads plus my new heads equals 10”, because my new heads is minus my old heads. This is the event of exactly 10 heads in 20 fair flips, and its probability is .
The same argument proves the identity , and for large the probability is about , here .
Classic wrong answer. One over 11, since there are 11 possible counts. The counts are not equally likely, and the central ones carry most of the mass.
Why it matters. The chance of an exact tie after rounds falls only with the square root of . Ties in a large sample are far more common than intuition suggests.
Question 7.26 ★★ QR, QT, QD, DS • any • junior
You form two random subsets and of a 10-element set, with each element put into each subset independently with probability . How likely is it that is contained in ? That and are disjoint? That they are equal?
Answer
Answer to Question 7.26.
Containment has probability , disjointness has the same probability, and equality has probability .
Each element acts independently, and each has four cases: in only, in only, in both, or in neither. For , only “in only” is forbidden, so each element contributes . So there are good pairs among .
For disjointness, only “in both” is forbidden, and again each element contributes . Complementing turns one into the other, which is why they are equal. For equality, an element must be either in both or in neither, which has probability .
Classic wrong answer. Conditioning on the size of , and summing over that size. It does give the same answer, by the binomial theorem, but the element-by-element view avoids any sum.
Follow-up. What about ? Each element has 8 cases, of which 4 are allowed: .
Question 7.27 ★★ QR, QT, Trader, QD • any • junior
You pick 3 chairs from 20 in a row so that no two are adjacent. How many choices are there? How many if the 20 chairs stand in a circle, with the last next to the first?
Answer
Answer to Question 7.27.
In a row there are 816 choices, and in a circle there are 800.
In a row, use a gap argument. Remove one chair from between each neighbouring pair of chosen chairs. Choosing 3 of 20 with no two adjacent then matches choosing 3 of chairs, with no condition. So .
In a circle, split on whether chair 1 is chosen. If it is, its two neighbours are out, and you need 2 non-adjacent chairs from the other 17 in a row: . If it is not, you need 3 non-adjacent from 19 in a row: . The total is 800. The general formula is .
The row and circle differ by those selections containing both end chairs, which are adjacent only on the circle. Fixing both, the third chair must come from chairs 3 to 18, which gives 16, and exactly.
Why it matters. The difference between a row and a ring is a recurring trap. A clean way to check a circular answer is to count what closing the row into a ring removes.
Question 7.28 ★★★ QR, QT, Trader • hedge fund, market maker • junior, experienced
Five couples sit in a row of 10 chairs at random. What is the probability that no couple sits together? Give the exact count.
Answer
Answer to Question 7.28.
The count is out of , or about .
Use inclusion-exclusion over the set of couples that sit together. Fix couples and glue each into a block. There are then objects, which can be arranged in ways, and each block has 2 internal orders, so the term is . So
The first two terms cancel exactly, which is a small surprise, and the sum is . The same formula gives 8 and 240 for two and three couples, which you can check by listing.
An approximation is a useful check. The expected number of couples together is , and if that number were Poisson with mean 1, the answer would be . The right answer is a bit lower, because the events are not independent, and it approaches for many couples.
Classic wrong answer. Multiplying as if the events were independent. Not bad as an estimate, but it is not exact, and an exact count was asked for.
Follow-up. How does a round table change it? Glued blocks arranged on a circle give arrangements with the same signs, and the count differs. Remember the factor for rotations.
Question 7.29 ★★★ QR, QT • hedge fund, market maker • experienced
How many subsets of , counting the empty set, have a sum divisible by 5? Do it without listing subsets.
Answer
Answer to Question 7.29.
There are 208 such subsets.
Use the roots-of-unity filter. Let , and consider . The coefficient of counts subsets with sum . Averaging over the five fifth roots of unity keeps exactly the terms where is divisible by 5:
At you have . For , the powers run twice through all fifth roots of unity as goes from 1 to 10, so . Since , putting gives . So each of the four terms is , and
The others share the remainder evenly, at 204 for each non-zero residue. So the distribution is almost flat, and the small excess for residue 0 is exactly what the filter sees.
Classic wrong answer. Answering , which is not even a whole number, or assuming perfect uniformity. Each block of holds a multiple of 5, so the residues are not perfectly balanced.
Follow-up. And for subsets of ? The powers run once through the roots, so . Listing them confirms it.
Question 7.30 ★★★ QR, QT, QD • any • junior, experienced
Three red and three green beads are placed evenly on a ring. How many different rings are there if rotations count as the same? How many if a ring can also be flipped over?
Answer
Answer to Question 7.30.
There are 4 rings under rotation, and 3 if flipping is also allowed.
Use Burnside’s lemma: the number of distinct rings is the average, over the symmetries, of the number of bead patterns that each symmetry leaves unchanged. There are patterns.
Under rotation, the identity keeps all 20. A rotation by one or five steps moves all beads in a single cycle, so it would need all beads the same: 0 patterns. A rotation by two or four has two cycles of length 3, so one must be red and the other green: 2 patterns each. A rotation by three has three cycles of length 2, and red would have to be even: 0. The average is . They are RRRGGG, RRGRGG, RRGGRG and RGRGRG.
Adding flips, three reflections through opposite beads each keep 4 patterns, because the two beads on the axis must differ and one of the other two pairs is red. The three through gaps keep none, because pairs make red even. The average is . The two mirror images RRGRGG and RRGGRG become one.
Classic wrong answer. Dividing by the 6 rotations, which gives . A pattern with symmetry has a smaller orbit, so simple division is wrong, and the lemma exists to correct it.
Question 7.31 ★★★ QR, QT, QD • any • junior, experienced
You paint each face of a cube one of two colours. How many different cubes can you make, if two cubes are the same when one can be rotated to look like the other? How many with three colours?
Answer
Answer to Question 7.31.
There are 10 cubes with two colours, and 57 with three colours.
Use Burnside’s lemma on the 24 rotations of the cube. A rotation fixes a colouring exactly when each cycle of faces it creates is one colour, so with colours a rotation with cycles fixes colourings. The rotations split by cycle count:
- the identity has 6 cycles (one rotation);
- a half-turn about the axis through two opposite faces has 4 cycles (three rotations);
- a quarter-turn about that axis has 3 cycles (six rotations);
- a half-turn about the axis through two opposite edges has 3 cycles (six rotations);
- a rotation about the axis through two opposite corners has 2 cycles (eight rotations).
This totals , and the number of cubes is
which gives 10 for and 57 for . With it gives 1, a useful check on the group count.
For you can list by number of faces of colour A, from 0 to 6: . These add up to 10, confirming the formula.
Classic wrong answer. , which is not even a whole number. Colourings with symmetry have smaller orbits.
Follow-up. And colourings using all six colours once each? No rotation except the identity fixes one, so .
Question 7.32 ★★★ QR, QT, Trader • any • junior, experienced
You choose 3 of the 12 corners of a regular 12-sided polygon at random. How likely is it that the triangle has a right angle? That it strictly contains the centre of the polygon?
Answer
Answer to Question 7.32.
A right angle has probability . Strictly containing the centre has probability .
There are triangles. By the angle in a semicircle, a triangle with vertices on a circle has a right angle exactly when one side is a diameter. There are 6 diameters and 10 choices of third corner, which gives 60.
Go round the polygon and write the three arcs between consecutive corners as whole numbers adding up to 12. A triangle strictly contains the centre exactly when each arc is below 6. An arc of exactly 6 is the right-angled case, and an arc above 6 leaves the centre outside the triangle (an obtuse triangle).
Count the obtuse ones. Fix the corner at which the largest arc ends, so that the other two corners lie within the next 5 steps: there are 12 choices for that corner and choices for the other two. So there are 120 obtuse triangles, and acute.
Classic wrong answer. Using , which is the answer for three uniform points on a circle. A finite polygon has right-angled triangles that take up probability, so the acute share is lower. As the number of corners grows, the answer does approach .
Follow-up. Three uniform points: why ? The arcs are a uniform point on a simplex, and the region where all arcs are below a half is the central triangle, a quarter of the simplex.
Question 7.33 ★★★ QR, QT, QD • hedge fund, market maker • junior, experienced
Show that any 10 different numbers chosen from 1 to 100 contain two disjoint non-empty groups with the same sum. Why does your argument not work for 7 numbers, and can you give 7 numbers for which no two different groups have equal sums?
Answer
Answer to Question 7.33.
Use the pigeonhole principle, comparing the number of subsets with the number of possible sums. For 7 numbers the count of subsets is too small to force a match, and the powers 1, 2, 4, 8, 16, 32, 64 have all their 127 subset sums different.
Any 10 numbers from 1 to 100 have non-empty subsets. Each has a sum between 1 and at most . There are more subsets than sums, so two different subsets have the same sum.
Those two may overlap. Remove their common elements from both: the sums stay equal to each other, and they stay different sets. Neither is left empty, because the numbers are positive, and if one set were emptied, the other would have to have sum zero. So you have two disjoint non-empty groups with the same sum.
For 7 numbers there are only 127 subsets, and sums can reach up to 679, so the pigeonhole argument gives nothing. The powers of two are a counterexample, because binary digits are unique. So the statement itself is false at 7, not just the proof.
Classic wrong answer. Trying to construct the two groups. The argument proves they exist without showing which they are, and that is the point of the question.
Why it matters. Pigeonhole arguments give very quick bounds, and the same comparison of counts gives a lower limit on the number of bits needed by a hash.
Question 7.34 ★★★ QR, QT, Trader, Risk • any • junior, experienced
A walk starts at 0 and takes 10 steps, each or with equal probability. What is the probability that it reaches at some point? Count it without listing paths.
Answer
Answer to Question 7.34.
The probability is .
Use the reflection principle. A path that reaches and ends below 4 can be flipped after its first touch of 4, and that gives a path ending above 4. This is a bijection. So
Paths ending at or above 4 must have 7 or more up steps: . Paths ending above 4 must have 8 or more: 56. The total is out of .
Classic wrong answer. Doubling , to get . The continuous-time formula does give a factor of two, but here the paths that end exactly on 4 must be counted once, not twice. That makes a big difference over only 10 steps.
Follow-up. What does the continuous limit say? Brownian motion over time reaches a level with probability , where exact hits have no mass. The difference falls with the number of steps.
Why it matters. This is the reflection used for barrier options: the chance of touching a level in a period is about twice the chance of ending beyond it. Near the level on a coarse grid, the discrete correction matters.
Question 7.35 ★★★ QR, QT, Trader, QD • any • junior, experienced
A six-digit ticket, from 000000 to 999999, is lucky if the sum of its first three digits equals the sum of its last three. How many lucky tickets are there? Find a way to count them from a single coefficient.
Answer
Answer to Question 7.35.
There are lucky tickets.
The trick is a bijection. Replace each of the last three digits by . A ticket is lucky when . After the replacement, , so the condition becomes . So you are counting six-digit strings whose digits add up to 27, which is a single coefficient: that of in .
Find this using stars and bars with inclusion-exclusion. With no ceiling, the number of solutions is . Subtract 6 times the number with one digit at least 10, which is , and add back 15 times the number with two such digits, . Three digits at least 10 would need 30, so you stop there:
Check by the direct sum of squares: for each value from 0 to 27, the number of three-digit strings with sum is squared and these are added up, which gives the same total. The peak term is at .
Classic wrong answer. Assuming that about 1 in 28 tickets is lucky, which is 35 714. Sums near the centre are much more likely, so a match is more likely than that: the true rate is about 1 in 18.
Question 7.36 ★★★ QR, QT, QD • any • junior, experienced
In how many ways can you fill a table with zeros and ones so that every row and every column has an even sum?
Answer
Answer to Question 7.36.
There are such tables.
Think of free choices. Fill in the top-left block in any way: that is choices. Each of the first four rows then has its last entry forced so that the row has even sum, and each of the first four columns has its last entry forced in the same way. Only the bottom-right corner remains.
The corner must fix both the last row and the last column, and these two demands agree. The sum of the last column’s top four entries and the sum of the last row’s first four entries are each the parity of the sum of the block: each is obtained by adding up the rows, or the columns, of the block. So the corner exists and is unique, whichever block you chose.
In general the count for is . Enumeration gives 2, 16 and 512 for , as it should.
Classic wrong answer. Counting equations and unknowns naively: 25 unknowns less 10 constraints leaves . The 10 equations are not independent, because the sum of all rows and the sum of all columns are the same sum, so one equation is redundant.
Why it matters. Parity grids are the idea behind RAID storage and simple error-correcting codes. The redundant equation is what lets you find a failed entry.
Question 7.37 ★★★ QR, QT, QD • hedge fund, market maker • junior, experienced
A permutation of has an ascent wherever an entry is followed immediately by a larger one. How many permutations of have exactly one ascent? Give a formula and its value for .
Answer
Answer to Question 7.37.
The count is , which is 26 for .
A permutation with exactly one ascent is two descending runs placed one after the other. Each is decided by its set of entries, because a descending run has only one order. So choose a subset for the first run: there are subsets, and the other entries form the second run.
Each permutation with one ascent arises from exactly one subset. But some subsets do not make an ascent. If the first run’s last entry is larger than the second run’s first entry, the whole thing descends, and there is no ascent. That happens exactly when is the set of the top values, for : that is subsets, each giving the single fully descending permutation. So the count is .
Enumeration agrees: gives 4, namely 132, 213, 231 and 312, and gives 11, gives 26, gives 57.
Classic wrong answer. Choosing where the ascent goes, with positions, and a subset of fixed size. That gives the right total only if you subtract the subsets at each size that make no ascent, and it is a slower route to the same count.
Follow-up. What are these numbers called? Eulerian numbers. They count permutations by their number of ascents, and they appear when you sum powers of integers.
Question 7.38 ★★★★ QR, QT • hedge fund, market maker • experienced
Find a pair of six-sided dice, with positive whole numbers on the faces and not both standard, whose sum has the same distribution as the sum of two ordinary dice. Show that it is the only pair.
Answer
Answer to Question 7.38.
The pair is and , known as Sicherman dice, and it is the only other pair.
Use generating functions. A die is a polynomial , and the sum of two dice has the product as its generating function. The target is
and these factors are irreducible over the integers. Polynomial factorisation is unique, so each die is a product of some of these. Two conditions apply to each die. First, it must have , because the faces are positive, so it takes one factor of . Second, it must have , because it has six faces. At , the factors take the values , and . To get 6, each die must take exactly one and one .
Only the factors, whose value at 1 is 1, can move. Sharing them gives standard dice. Sharing them gives
and .
A computer search of all face sets confirms it: there are exactly these two solutions.
Classic wrong answer. Searching by hand with “the two dice must sum to 42 together”. It is a true necessary condition, but it does not lead you to the pair, and it proves nothing about uniqueness.
Follow-up. Three dice? The same factorisation has more possibilities, and there are non-standard triples, also found by moving the factors.
Question 7.39 ★★★★ QR, QT • hedge fund, market maker • experienced
Five couples sit around a round table, alternating men and women, so that nobody sits next to their partner. Rotations count as the same seating. How many seatings are there? What is the probability that a random alternating seating qualifies?
Answer
Answer to Question 7.39.
There are 312 seatings, and the chance that a random alternating seating qualifies is .
This is the ménage problem. Fix one man to remove the rotations: the other men can be placed in ways. Between men there are five places for the women, and each woman is barred from two adjacent places: the ones beside the matching partner. So you need the number of assignments of 5 women to 5 places, with these barred positions, and this number does not depend on how the men sit.
The bars form a single ring of 10 cells: woman, place, woman, place, and so on. Choosing violations is choosing cells of the ring with no two neighbouring, because a woman or a place cannot be used twice. There are such choices, and the others are placed freely, so by inclusion-exclusion,
The total is , out of alternating seatings. Checking all 2 880 by machine gives the same count, and the formula also gives .
Classic wrong answer. Treating each woman as independently having a chance of a valid place, which gives . The choices compete for places, and they are far from independent.
Follow-up. For large ? Each woman has 2 barred places out of , so the expected number of violations is 2, and the fraction tends to , which is a fair check here.
Question 7.40 ★★★★ QR, QT, Trader • hedge fund, market maker, bank • experienced
A hundred prisoners are numbered 1 to 100. A room holds 100 boxes, also numbered, with the prisoners’ numbers placed in them in a random order, one in each. One at a time, each prisoner enters and may open 50 boxes, then leaves everything as it was, and may not communicate with the others afterwards. All are freed if every prisoner opens the box holding their own number. They may agree on a plan beforehand. What plan is best, and what is its chance of success, roughly?
Answer
Answer to Question 7.40.
Each prisoner should start at the box with their own number and follow the numbers inside. The chance of success is , compared with for random guessing.
Each box holds a number that is the label of another box, so the boxes form a permutation. If a prisoner opens box , finds the number , then opens box and so on, the prisoner walks along the cycle that contains . That cycle ends at the box holding , which is exactly what the prisoner wants. So the prisoner succeeds if and only if the cycle is at most 50 long. All succeed if and only if the permutation has no cycle longer than 50.
A permutation of 100 has at most one cycle longer than 50. The number of permutations with a cycle of length exactly is found by choosing its elements, , arranging them in a cycle, , and arranging the rest, . This is . So the chance of a long cycle is , and success has probability about .
The strategy works because success is highly correlated: all prisoners succeed or fail together, depending on one property of the permutation.
Classic wrong answer. “Each has , so it is whatever they do, because nobody can pass information.” The individual chance really is . What the plan changes is the correlation between them, and independence is what is being given up.
Why it matters. It is the best example of a pattern that matters for risk: you cannot change a position’s marginal behaviour, but correlation decides what happens to all the positions together.