by Matt Parker
There are twenty-one ways to join two bricks going in the same direction and twenty-five ways going in different directions. A total of forty-six options, and only the two centre ones are symmetric.
Then one day mathematician Søren Eilers was walking around Legoland in Denmark and was unsatisfied with the 102,981,500 number he saw on display. Some time later in his office at the University of Copenhagen, he set about working out the number for combining six two-by-four Lego bricks but factoring in that the bricks could be placed next to each other as well as on top of each other. This was not a calculation that could be done by hand. Even with six Lego bricks, the number of ways they can be attached to each other is too great to be counted by a human. A computer would have to explore all the possible options and keep count of them. This was 2004, and computers were a lot more powerful than in 1974, but it still took half a week to produce the answer: 915,103,765.
To make sure his number was right, Eilers gave the problem to a highschool student, Mikkel Abrahamsen, who was looking for a mathematics project. The code Eilers used was written in the Java programming language and run on an Apple computer. Abrahamsen came up with a new way to explore the combinations and programmed it in Pascal to run on an Intel machine. Both completely different methods gave the same answer of 915,103,765, so we can be fairly confident it is correct.
Because calculating combinations can give such large numbers, they are often used in advertising. But very rarely do companies bother trying to get the answer correct. When combinatorist (a mathematician who specializes in combinatorics) Peter Cameron went to a pancake restaurant in Canada he noticed that they advertised a choice of ‘1,001 toppings’. Being a combinatorist, he recognized that 1,001 is the total number of ways to pick four things out of a total of fourteen options, so he figured they had fourteen toppings and customers could choose four. Actually, the restaurant had twenty-six toppings (he asked) and had picked ‘1,001’ just because it sounded big. Had they done the maths correctly, those twenty-six toppings in fact allowed for 67,108,864 options. A rare case of marketing understatement.
Similarly, in 2002 McDonald’s ran an advertising campaign in the UK to promote its McChoice Menu, which consisted of eight different items. Posters around London promised that this gave the customer a choice of 40,312 options, a number that is not only wrong but comes with a side order of extra wrong. And what makes this a special case is that when their errors were pointed out McDonald’s did not admit its mistake but doubled-down on trying to justify its bad maths.
Calculating the number of combinations of eight menu items is reasonably straightforward. Imagine being offered each of the options one at a time. Do you want a burger: yes or no? Do you want fries with that: yes or no? There are going to be eight yes-or-no choices, so you have 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 = 28 = 256 total options. This includes choosing to eat nothing from the menu, choosing to eat everything from the menu and every combination in between. If eating nothing does not technically count as a meal, then that leaves 255 meal options (although some people would argue that the ‘null meal’ is their favourite thing to order from McDonald’s).
The number McDonald’s used was the result of a very different calculation. It’s the answer to the question of how many different ways you could arrange eight menu items. In this case, imagine that you have all eight items in front of you and you need to eat them one at a time. You have eight options for what you eat first, seven options for what you eat second, and so on: 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 8!fn2 = 40,320 ways to eat a meal of eight parts. It’s a bit optimistic of McDonald’s to assume that people will simply order all eight menu items and then try to find their favourite order to stuff it all into their face. (At three meals a day, it would take nearly thirty-seven years to try them all. That’s a long time to spend in the House of Ronald.)
Then came the extra mistake on the side, which I think was actually the one moment of clarity McDonald’s had. They decided that a ‘combination’ requires at least two items to be combined, so they subtracted eight from their total, to remove the one-item options. Of course, the calculation they originally did was not in any case the number of combinations, so the end result was meaningless.fn3 And even if they had got all that correct, they forgot to remove the null meal from their count. In reality, the number of combinations of two or more items from a menu of eight things is 247. Much smaller than 40,312. Like a kind of anti-super-sizing.
So much smaller that 154 people complained to the UK Advertising Standards Authority that McDonald’s was grossly overstating how much choice its McChoice Menu really offered. Now obliged to argue their case, McDonald’s did not admit its maths was wrong. Instead, the company did that classic ‘definitely innocent’ move of coming up with two mutually exclusive excuses, like a guilty child saying there never was a hamburger and, besides, it was their sibling who ate it.
First, when confronted with the information that the number of ways you can arrange a meal is irrelevant, McDonald’s declared it wasn’t. From the ASA ruling:
The advertisers said they were aware that some people might consider a double cheeseburger and milkshake to be the same permutation as a milkshake and double cheeseburger but they believed that each permutation could be considered a different eating experience.
I’m not even going to address their use of the word ‘permutation’ here, because it would distract from the fact that McDonald’s seriously argued that eating the burger or drinking the milkshake first makes the experience two different meals. Don’t anybody tell them that, rather than eating their meals in series, some people consume the items in parallel, allowing for a gastronomical number of possible meals.
Having committed to the fact that the company definitely wanted to calculate the number of arrangements of the meal (its reply even used the technical name for that calculation: a ‘factorial’), McDonald’s also decided that 40,312 was not the result of a calculation but was merely illustrative. They argued that the real calculation would involve the different flavour variations of some of the menu items (for a new total of sixteen distinct meal components), giving a total number of combinations greater than 65,000. Which is correct! (216 = 65,536.) But it includes things like walking into McDonald’s and ordering one of every flavour of milkshake and calling that a meal.
The Advertising Standards Authority eventually ruled in favour of McDonald’s and did not uphold the complaints. They noted that McDonald’s had put an incorrect number on its advertising but decided that the company was intending only to indicate that there were a lot of choices and that the total of ‘over 65,000’ was bigger than the actual number of combinations promised. But people were not lovin’ it. An appeal was lodged to complain that an advertiser should not be able to retrospectively change the calculation behind a number used in an advertisement. The appeal was denied. And that was that.
Even though decades have passed, I’m going to reopen this cold case (it probably hasn’t gone off) and take one last look at the facts. I’m going to count sensible meals only. The eight items on the McChoice Menu could be combined in different types of snacks and meals as would be enjoyed by one person. I think we can cover every reasonable meal with:
Drink options:
Four soft drinks, four milkshakes, or no drink at all: 9
Meal options:
Cheeseburger, Filet-O-Fish or a hotdog.fn4 I’m allowing people to have no main (one option), one of these (three options) or two of these if they’re really hungry (possibly the same thing twice); 6 options: 1 + 3 + 6 = 10
Would you like fries with that?
Yes or no: 2
Dessert options:
Apple pie, three flavours of McFlurry or the four milkshakes. Even if they had a milkshake for their main drink, I’m not going to judge anyone who wants another milkshake for dessert. With skipping dessert as an option: 1 + 3 + 4 + 1 = 9
So that gives us:
9 × 10 × 2 × 9 = 1,620
Remov
ing the null meal leaves 1,619 legitimate combinations of items from the menu. It’s possible to argue I’ve missed some combination people might actually order, but I’m pretty sure McDonald’s doesn’t want to be using their advertising to suggest people walk in and eat seven hotdogs in a row. The would be a very unhappy meal.
Is your perm big enough?
Sometimes the number of options allowed can result in serious limitations. In the US zip codes are five digits long and go from 00000 to 99999: a total of just a hundred thousand options. Given the US has a total land surface area of 9,158,022 square kilometres, this gives just under 100 square kilometres per potential zip code. They can never be more accurate than that (on average). This does help narrow down the delivery of mail, but the rest of the address is needed for finer resolution.
It can be worse: Australia uses four-digit postcodes with an area comparable to the US (7,692,024 square kilometres), so each postcode has on average 769 square kilometres to deal with. But thanks to a small population, that is only around 2,500 people per postcode, whereas the US has around 3,300 humans per zip. Those numbers assume an evenly distributed population and, in my experience, people like to clump, which will mean more humans per postcode. I just looked up the Australian postcode where I grew up (6023) and, as of 2011, there were 15,025 people living in 5,646 different dwellings.
Now I live in the UK, and if I look up my home postcode there are only thirty-two addresses. That’s it. All on the same street. UK postcodes have much finer resolution than Australia or the US. The building my office is in has a postcode all to itself, a postcode that points at a single building. I can give my address as just my name and my postcode. To Americans and Australians, that sounds ridiculous.fn5
The UK makes it work by having longer postcodes and allowing letters, digits and strategic spaces. There are some limitations on where letters and digits can be positioned, but this system still allows for a staggering 1.7 billion possible postcodes.
Some example postcodes. I have worked at two-thirds of these.
27 × 26 × 10 × 37 × 10 × 26 × 26 = 1,755,842,400
To be fair, that is an overestimate because some of the letters in a UK postcode describe the geographic area. The ‘GU’ in my example is for the Guildford area; ‘SW’ and ‘E’ are the south-west and east parts of London respectively. If the UK wanted to really max out its postcode format by allowing all letters and digits in any positions of two groups of three or four symbols each, then there would be 2,980,015,017,984. Enough for one unique code for each patch of ground of about 30 square centimetres. I think that’s a great idea. When I do my online grocery shopping, I could give each thing I’m ordering the delivery address of the exact cupboard it needs to end up in.
Phone numbers solve the same problem of assigning numbers to people, but in this case we really do need a one-to-one match-up. Originally, there was one phone number per house and, now, with mobile phones, we’re down to a number per human. But there are not enough numbers to go around.
Back in the past, calling long distance or international was outrageously expensive, so phone companies would try to undercut the rates of other companies in ways that avoided customers having to change provider. They’d provide a toll-free number to ring, after which an ID code could be entered and then the number you actually wanted to call. The cost of this second call, now bouncing via the intermediate company, would be charged to the account matching the ID code.
The problem was that these intermediate companies did not pick long enough codes. People online talk about how some companies would only use five-digit codes, despite having tens of thousands of customers. Five digits allows for a hundred thousand possible codes, and ten thousand customers would use 10 per cent of those. In maths, we’d say that the space of possible codes is saturated to the rather high proportion of 10 per cent. At fewer than ten possible codes per customer, it would not take long to guess a valid one and make a ‘free’ call. This kind of security through obscurity works only if the number of possible codes swamps the ones which are valid.
It even seems that the number of humans on earth is at a high saturation rate of the number of possible phone numbers. If there were way more phone numbers than people, they would be disposable (the phone numbers, not the humans). But because phone numbers, historically, needed to be memorized, there has been pressure to keep them short. Thus there are not enough of them to throw away so phone numbers get recycled; when you cancel a phone contract, your number is not deleted: it’s given to someone else. The chance of a number directly linked to your personal information eventually being reallocated to someone is a definite security risk.
My favourite recycled-phone-number story comes from the Ultimate Fighting Championship. The UFC is a mixed-martial-arts competition which I am vaguely aware of only because the fighting ring is an octagon and directly referred to as such. I’d say calling a television show ‘Road to the Octagon’ and then just showing a bunch of fighters is false advertising. And don’t get me started on how few higher polygons were in ‘Beyond the Octagon’.
Welterweight UFC fighter Rory MacDonald noticed that whenever he walked out before a fight they would not play the walk-out song he requested. His opponents were picking aggressive songs to get them in the mood, and these were being played, but his choices seemed to be disregarded. I imagine trying to get in the zone before a fight is not helped by the unexpected blasting of MC Hammer’s ‘U Can’t Touch This’. Other fighters were making fun of his music choices.
This carried on until, one day before a fight, the producer came up to Rory and apologized for not being able to play the Nickelback song he had requested. Rory claimed he had never asked for such a thing and the producer showed him the text messages where he had. An old phone number of Rory’s had been recycled and accidentally given to a UFC fan who had been happily picking Rory’s music for him. It’s a great story about the limitations of number combinations and the first recorded time Nickelback caused someone to stop suffering.
SIX
Does Not Compute
Gandhi is famous as a pacifist who led India to independence from the UK. But, since 1991, he has also gained a reputation as a warmonger leader who launches unprovoked nuclear strikes. This is because of the Civilization computer games, which have sold over 33 million copies. They pit you against several world leaders from history in a race to build the greatest civilization, one of whom is the normally peace-loving Gandhi. But ever since early versions of the game, players noticed that Gandhi was a bit of a jerk. Once he developed atomic technology, he would start dropping nuclear bombs on other nations.
This was because of a mistake in the computer code. The game designers had deliberately given Gandhi the lowest non-zero aggression rating possible: a score of 1. Classic Gandhi. But later in the game, when all the civilizations were becoming more, well, civilized, every leader had their aggression rating dropped by two. For Gandhi, starting from 1, this calculation played out as 1 − 2 = 255, suddenly setting him to maximum aggression. Even though this error has since been fixed, later versions of the game have kept Gandhi as the most nuke-happy leader as a tradition.
The computer was getting an answer of 255 for the same reason computers have trouble keeping track of time: digital memory is finite. The aggression ratings were stored as an 8-digit binary number. Starting at 0000001 and counting down two gave 00000000 and then 11111111 (which is 255 in normal base-10 numbers). Instead of becoming negative, a number stored in a computer will wrap-around to being the maximum possible value. These are called roll-over errors, and they can break computer code in really interesting ways.
Trains in Switzerland are not allowed to have 256 axles. This may be a great obscure fact, but it is not an example of European regulations gone mad. To keep track of where all the trains are on the Swiss rail network, there are detectors positioned around the rails. They are simple detectors which are activated when a wheel goes over a rail, and they count how many wheels there are
to provide some basic information about the train which has just passed. Unfortunately, they keep track of the number of wheels using an 8-digit binary number, and when that number reaches 11111111 it rolls over to 00000000. Any trains which bring the count back to exactly zero move around undetected, as phantom trains.
I looked up a recent copy of the Swiss train regulations document and the rule about 256 axles is in there between regulations about the loads on trains and the ways in which the conductors are able to communicate with drivers.
This roughly translates as ‘In order to avoid the danger of an unintentional all-clear signal for a railway section because of the reset to zero of the axles counter, a train must not have an effective total number of axles equal to 256.’
I guess they had so many enquiries from people wanting to know exactly why they could not add that 256th axle to their train that a justification was put in the manual. This is, apparently, easier than fixing the code. There have been plenty of times where a hardware issue has been covered by a software fix, but only in Switzerland have I seen a bug fixed with a bureaucracy patch.
There are ways to mitigate roll-over errors. If programmers see a 256 problem coming, they can put a hard limit in place to stop a value going over 255. This happens all the time, and it’s fun spotting people getting confused at the seemingly arbitrary threshold. When messaging app WhatsApp increased the limit on how many users can be in the same group chat from a hundred to 256, it was reported in the Independent with the description: ‘It’s not clear why WhatsApp settled on the oddly specific number.’