How many people have X and Y?

I have a problem for which I know the answer, but have no idea why it works.

Of 40 people, 30 have a condition. 15 have condition X and 25 have condition Y. How many people have both X and Y?

I know the answer is 10 (thanks to the answers sheet) but why? When I simulate the question by giving random people X's and Y's, and count the people with both, I get answers ranging from 8 to 13. Is my simulation off? Is my thinking wrong?

Why would it be 10, all the time?

Only theory is 15+25=40, 40-30=10, but this doesn't seem logical. (25-15=10, but that's just coincidence right?)

-
In your simulation, you should check that the number of people you have assigned $X$ is actually 15, and those assigned $Y$ is actually 25. – Paresh Jan 24 '13 at 14:13

Suppose that you are in a hall with two doors marked $X$ and $Y$. You have $40$ people in front of you. Ten of these don't have a condition so ask them to leave.

Now ask all of the people with condition $X$ to go into room $X$. There are 15 people in there. There were 30 in front of you so now there are only 15.

But 25 people have condition $Y$ so ten of these must already be in room $X$; so ten people have conditions $X$ and $Y$.

PS: Of course you can answer this using Venn Diagrams but I sometimes get frustrated with students who try to apply "mathematical methods" to a problem which they could probably do were it not posed as a maths problem but rather a riddle in a newspaper or TV show.

-

Use the law $n(X \cup Y)=n(X)+n(Y)-n(X \cap Y),$ where $n(A)$ means the number of elements in set $A$. In your case, you know $n(X \cup Y)$ and also know $n(X),n(Y).$

EDIT: Note that the 40 in "Of 40 people..." has no effect. The same answer of 10 would result if this phrase were replaced by "Of 1000 people." Only the people having a condition can count toward those having both conditions X and Y.

-

There are only 30 people with the condition.

Hence, of the 15 people with X only 5 have specific condition X. Others share it with condition Y.

This is because condition Y is related to 25 people of the 30. Hence, only 5 of those are left out with condition X. But total people with X were 15.

Hence, you get the answer as 10.

-

On second thoughts, there's an easier way. 30 people have either X or Y. 15 people have X. So of the 30 people, 30 - 15 people don't have X (which means they have only Y). Similarly, of the 30 people, 30 - 25 people don't have Y(which means they have only X). So number of people with only X or only Y = 15 + 5 = 20. So people with both X and Y = 30 - 20 = 10.

-

I misunderstood the question earlier. By condition you mean symptom - which means that there could be people with a disease who don't have either symptom X or Y. I am posting a new answer:

Total no. of people = 40 = number of people with only symptom X + Number of people with only symptom Y + number of people with both symptom X and Y + number of people with neither symptom X or Y.

number of people with neither symptom X or Y = total population - people with either symptom = 40 - 30 = 10

Number of people without symptom X = total population - people with symptom X = 40 - 15 = 25

number of people with only symptom Y = people without symptom X - people with neither symptom = 25 - 10 = 15

number of people without symptom Y = total population - people with symptom Y = 40 -25 = 15

number of people with only symptom X = people without symptom Y - people with neither symptom = 15 - 10 = 5

therefore total number of people with only X or only Y symptom = 15 + 5 = 20

therefore total number of people with both X and Y = Total number of people with either symptom X or Y - total number of people with only X or only Y symptom = 30 - 20 = 10

-
-1 What if there are 40 people with a disease... – Jp McCarthy Jan 24 '13 at 13:30
Didn't understand your comment.Could you elaborate?It's given in the question that (15 + 25 = 40) people have a condition.The statement 30 people have a condition doesn't make sense (or is it 30 people don't have a condition)? – Nikhil Panikkar Jan 24 '13 at 13:39
By condition are you referring to symptom?Ok, then I understand. – Nikhil Panikkar Jan 24 '13 at 13:40
Sorry when I say disease I mean condition. Do you see how your solution is wrong? The question says that 30 people have a condition not 40. If 40 have a condition out of forty people then none have both: 15 have $X$ and 25 have $Y$. – Jp McCarthy Jan 24 '13 at 14:01
That's wrong. 15 have X doesn't mean that all 15 don't have Y. – Nikhil Panikkar Jan 24 '13 at 14:10