Tag Archives: probabilities

Hannah Sweets Maths Problem – Edexcel (June 2015)

In this post I’ll be demonstrating how to solve the “Hannah Sweets” maths problem which was posed in an Edexcel exam paper around June 2015. This problem is in fact one which is related to probabilities and goes like this:

There are (n) sweets in a bag;

6 of the sweets are orange;

The rest of the sweets are yellow;

Hannah takes at random a sweet from the bag… She eats the sweet;

Hannah takes at random another sweet from the bag… She eats the sweet;

The probability that Hannah eats two orange sweets is 1/3;

Show that: n^2 – n – 90 = 0.

[Source: Edexcel]

At first sight, this question could look a bit tedious, but upon further inspection – we notice that it can be broken into parts and solved fairly easily. Let me explain how…

Firstly, because of the information provided above, we can say that the probability of finding an orange sweet in the bag (under initial conditions) is 6/n. Note that we were told that there are 6 orange sweets in the bag (to begin with) and (n) sweets in the bag in total.

Now, as the rest of the sweets in the bag are yellow, what we have under initial conditions is an (n-6)/n chance of finding a yellow sweet in the bag. This expression happens to be irrelevant though, because we are told: 1. The probability that Hannah eats two orange sweets is 1/3. 2. Show that n^2 – n – 90 = 0.

What we really need is to find the chances of finding a second orange sweet after taking one orange sweet out of the bag… The chances of this happening would be 5/(n-1) because if you take one orange sweet out of the bag, 5 will be left and (n-1) sweets will be left.

Using our most basic probabilistic theorems we can deduce that the probability of selecting two orange sweets out of the bag in a row would be:

(6/n) * (5/(n-1))

Since we’ve been told that the probability that Hannah eats two orange sweets in a row is 1/3, we can say that:

(6/n) * (5/(n-1)) = 1/3

This would give us the equation:

30/(n(n-1)) = 1/3

Which would in turn give us:

90/(n(n-1)) = 1


n(n-1) = 90

Therefore we’d get:

n^2 – n = 90

And finally:

n^2 – n – 90 = 0.

From here on we’d only have to solve this quadratic equation to figure out how many sweets were in the bag to begin with. It turns out that n=10.

Binomial Expansions on Python

The other day I was asked to solve a complex probability problem. This probability problem was related to a vocabulary quiz which was being circulated around the web. It is a vocabulary quiz which contains 15 questions with 2 two possible answers to each question. My goal was to simply state the chances of someone (with a terrible vocabulary) answering at least 7/15 questions in this quiz correctly without referring to Google or any other search engine… Their answers to these questions were going to be completely random.

Now, in order solve this probability problem I first had to acknowledge seven essential facts:

1) The person taking this quiz has a terrible vocabulary and just wouldn’t be able to answer any of the questions in this quiz with confidence;

2) The person answering these questions would be providing random answers to them;

3) The person taking this quiz isn’t allowed to use any tools/resources which would help him/her answer these questions correctly;

4) There were only two possible answers to each question (right (R) or wrong (W) answers);

5) Each answer to these questions were mutually exclusive, in other words, selecting the right answer to one question wouldn’t increase your chances of answering any other question correctly ;

6) There were 15 questions in total;

7) A binomial distribution  would be required to solve the problem as there were two mutually exclusive outcomes to each question being answered.

With these facts in mind I knew exactly what I had to do to solve this problem, however, expanding the expression (R+W)^15 was going to be a very tedious task indeed and would require plenty of manual labour.

Was there another way to solve this problem?? Could a computer program help me solve the problem more easily??

Well it turned out that I would be able to solve the problem more easily, but that I’d have to use Python (a high level general purpose programming language) including an “add on” called Sympy to achieve such a feat. So what I essentially did was install both Python(x, y) and Sympy on my Windows laptop.

*You can find out how to download both Python and Sympy by watching the video below:

I then searched “Python IDLE” on my laptop and opened up Python’s shell application. This is what I typed into the application:

(R+W)^15 Expansion - Python

If you look at the image above carefully you will see that this Python shell application (thanks to the help of the “add on” Sympy, including some handy code) was able to expand (R+W)^15 for me… In fact, it did it in a split second.

From the moment (R+W)^15 had been expanded, to solve the problem I had been asked to solve, all I had to do was:

i) Sum up the coefficients of the variables (R, W) included in the expansion;

ii) Place this sum (a) under the value of the sum of coefficients sitting beside R variables with exponentials greater or equal to 7 (b) – in a fraction b/a.

This fraction (b/a) would give me the probability / chances of someone randomly being able to answer at least 7/15 questions correctly in the vocabulary test under the conditions which had been set.

a = 2(1 + 15 + 105 + 455 + 1365 + 3003 + 5005 + 6435) = 32,768

b = 1 + 15 + 105 + 455 + 1365 + 3003 + 5005 + 2(6435) = 22,819

b/a = 22,819/32,768 = 0.70 (to 2 decimal places)

Solution to problem: 70% chance

Now the irony of the story is this… I gave myself this problem to solve because my “posh” vocabulary is horrendous. It turned out that I managed to get 9/15 questions in the vocabulary test correct and all my answers were guesses. 🙂

Thanks for reading!!