How to find the highest possible number of quantity in both categories? This question seemed pretty easy to me, but I have the wrong answer according to my textbook.
In a graduating class of 236 students, 142 took algebra and 121 took chemistry. 
What is the greatest possible number of students that could have taken both?

If all 121 students in chem took both classes, that would leave 121 + (142-121) = 142 which is much smaller than our graduating size, so not all students in Chemistry can be in both. My answer was 27, since
1 = P(algebra) + P(chemistry) - P(both)

Where I figured P(both) = 27/236 since P(algebra) + P(chemistry) = 263/236
But the book is telling me the actual answer is 121. What is the right way to determine the greatest possible number of things participating in 2 categories?
 A: You calculated the smallest possible number of students that could have taken both.
It could be that $121$ students took both algebra and chemistry, another $21$ took algebra, but not chemistry, and the remaining $94$ took neither.
(the question doesn't say each student took at least one of the two courses!)
A: 
To solve this problem you want the greatest possible value of $x$. It is clear from the diagram that $x$ cannot be greater than $142$ nor greater than $121$, otherwise or would be negative. Hence, $x$ must be less than or $142−x, 121−x$ equal to $121$. Since there is no information to exclude the correct $x=121$
A: Your problem belongs to linear programming. Linear programming is a technique of maximizing or minimizing a linear function subject to linear constraints and inequalities.
Let's convert your problem to a linear programming problem. This goes along the lines of @absolute friend's answer. The cardinality (number of elements) of any subset of students is non-strictly positive (non-negative). This means that:


*

*the number of students that took algebra and chemistry is non-strictly positive, $x\geq 0$,

*the number of students that took algebra but not chemistry is non-strictly positive, $142-x\geq 0$, equivalently, $142\geq x$,

*the number of students that took chemistry but not algebra is non-strictly positive, $121-x\geq 0$, equivalently, $121\geq x$,

*the number of students that took neither algebra nor chemistry is non-strictly positive, $236-142-(121-x)\geq 0$, equivalently, $x\geq 27$.


All these constraints are equivalent to $27\leq x\leq 121$. You need to maximize $x$. Obviously, the greatest value of $x$ satisfying the constraints is $121$. Minimization is similar.
Of course, not all linear programming problems are so easy.
