# How to put 9 pigs into 4 pens so that there are an odd number of pigs in each pen?

So I'm tutoring at the library and an elementary or pre K student shows me a sheet with one problem on it:

Put 9 pigs into 4 pens so that there are an odd number of pigs in each pen.

I tried to solve it and failed! Does anybody know how to solve this? This question seems ridiculously difficult and impossible IMO.

• Surely you are not suggesting that school teachers would never ask a trick question? – Old John Nov 7 '13 at 1:11
• The question fails to make it clear that a total number of 9 pigs is to be distributed into four pens; a possible interpretation is simply to put 9 pigs into each of four pens. This kind of imprecise language is one reason why users ask for one thing, but the software which is implemented does something else. :) – Kaz Nov 7 '13 at 3:34
• This question is silly. You can't fit nine pigs into a pen. Only ink goes in pens. You have to liquidize the pigs into pig ink, and then you can divide the pig ink equally into four portions. – Crashworks Nov 7 '13 at 3:43
• As far as I know, in my Ontarian school board, teachers ("good" or "bad" alike) wouldn't give questions like these without explicitly telling them that they are meant to be riddles. It would hurt the confidence of the students and become political. Perhaps this child knew it was a riddle and wanted to share it for the fun of it. – SimonT Nov 7 '13 at 4:06
• One does not simply... imgur.com/vF5b3mf – Simone Nov 8 '13 at 10:16

It appears to be a trick question.

Make 3 pens, put 3 pigs in each pen. Then put a 4th pen around all 3 of the other ones, and you have 9 pigs in that pen.

Update

@MJD found a source for this problem with solution, see Boys' Life magazine from 1916.

• The trick is good (though I do not see why not just to build 4 nested pens and put all pigs into the innermost one). There are many other solutions in the same spirit (using the ambiguity in the problem statement). We can build 4 disjoint pens, put one pig in each of the first 3 and 6 in the fourth and let somebody try to convince us that there aren't 3 pigs in the last pen (if we have 6, we certainly can point out three (an odd number) of them that are in the pen). Another option is to have one extra pig in one pen (that the pens must be empty is as unclear as that they must be disjoint). – fedja Nov 7 '13 at 2:01
• Basically, this is a riddle, not a maths question. – TRiG Nov 7 '13 at 2:58
• Even simpler: if pens can be nested, then simply make this quadruple-walled pen: [[[[ 9 pigs ]]]]. Why go through all the trouble of dividing into groups of three? – Kaz Nov 7 '13 at 3:36
• I wonder how well this riddle would go over with an 8-year old who lives on a farm? Surely farmers don't nest pig pens and would not even consider thinking about such a thing valid? – Michael Nov 7 '13 at 19:10
• @Michael I wonder if this is also harder for those familiar with sets, who'd point out that $\{\{\{\{\bullet\}\}\}\}$ isn't four sets each containing $\bullet$, but a three sets that each contain one set, and one set that contains $\bullet$. Those familiar with strongly typed collections in programming languages would also complain that you can't put a Pig into a Set<Set<Pig>>. – Joshua Taylor Nov 7 '13 at 22:12

Since this has been exposed, some claim, to be a riddle and not a bona fide math question, why not completely drive the stake through its heart:

Pen 1: 7 pigs

Pen 2: 1 pig

Pen 3: 3 pigs

Pen 4: -2 pigs

Now the astute reader will note that -2 pigs is a pretty darn odd number of pigs to be in a pen!

• If anyone needs me, I am ducking under the table, well shielded from flying erasers. – Kaz Nov 7 '13 at 3:40
• -2 may be even, but the concept of -2 pigs is indeed quite odd. – András Hummer Nov 7 '13 at 8:38
• -2 pigs = 500 pounds of bacon ? – kriss Nov 7 '13 at 8:54
• Really nobody got it? Of course -2 is even! That's a cool answer! Check the meaning of "odd", it also means unusual, absurd. What he meant is "It's really absurd for -2 pigs to be in a pen." – Zafer Sernikli Nov 7 '13 at 14:29
• I have known this question/riddle for nearly half a century, and never expected to see still another good valid answer. – Pieter Geerkens Nov 10 '13 at 1:58

Lemma: $-\frac{1}{12}$ is an integer.

proof: Consider the Riemann zeta function $\zeta$ evaluated at $-1$. By analytic continuation, $\zeta(-1) = -\frac{1}{12}$. However, we also have the series expansion $\zeta(s)=\displaystyle \sum_{n=1}^\infty n^{-s}$, so (ignoring issues with convergence), $\zeta(-1)=1+2+3+\cdots$. This is an infinite sum of integers. Any finite sum of integers is an integer, and the since the integers are a closed set (and hence contain all limit points) this also holds in the limiting case. Hence $-\frac{1}{12}$ is an integer.

Corollary $\frac{2}{3}$ is odd.

proof: By above, since $-\frac{1}{12}$ is an integer, $4 (-\frac{1}{12})=-\frac{1}{3}$ is an even integer. Since the successor of any even integer is odd, $-\frac13 +1 = \frac23$ is odd.

Theorem It is possible to put 9 pigs in 4 pens such that each pen has an odd number of pigs.

proof: For the first pen, put $7$ of the pigs in. Cut the remaining $2$ pigs into equal thirds and put two of the thirds in each of the remaining pens. Since $7=2\times3+1$, $7$ is odd. By corollary above, $\frac23$ is odd. Hence all four pens have an odd number of pigs.

Note: The above is humor.

• Interesting how Riemann shows up everywhere! – zerosofthezeta Nov 7 '13 at 8:08
• It is true that $\frac 23$ is an odd integer! – Asaf Karagila Nov 7 '13 at 14:42
• ^^^ thank you, poindexter. it was a joke. – Jonathan Landrum Nov 7 '13 at 18:42
• @JonathanLandrum poindexter - that just became my favorite word! – zerosofthezeta Nov 8 '13 at 22:48
• It's quite easy to put 9 pigs into four pens such that each pen has an odd number of pigs. Build the first pen and put all nine pigs into the pen. Then build the remaining three pens such that each pen encloses all the pens which existed prior to starting construction of the next pen. Share and enjoy. – Bob Jarvis Jan 11 '14 at 2:48

It's not possible. Adding an even number of odd numbers will give an even number: $(2a+1) + (2b+1) = 2(a+b+1)$.

• This is the correct solution. Kids who grow up on trick questions just end up being a bunch of smart ass. Methodological, evidence based argument should be what they are accustomed to. – Sleeper Smith Nov 7 '13 at 3:16
• @SleeperSmith but what if life is a trick question? – Andy Nov 7 '13 at 4:47
• @AndyPryor Trust me it isn't. Your parents would've picked your high school, college doctor/law degree, PHD, arranged marriage, asked favor for you to start at a big firm, decided the number of kids you should have.... If you are a chinese. (I'm a chinese. No that's a tongue in cheek joke. :p) – Sleeper Smith Nov 7 '13 at 4:50
• @SleeperSmith There is something to be said for this from the standpoint of mastering technique, sir. But don't you think a dose of these "trick" questions might encourage creative thinking? This might be a soft skill, but it is an important one, especially for the many who do not pursue a rigorous adult eduction (many adults), or who must make abstract connections (ie, politicians.) – user1833028 Nov 8 '13 at 5:15

Put 9 pigs into 4 pens so that there are an odd number of pigs in each pen.

What about the simplest solution? The case where the pens are 'embedded' within each other:

Four pens, Nine in each. Nine is odd.

• Oops, just realised there are a couple of similar answers. Will leave this for pictorial representation. – azz Nov 7 '13 at 14:08
• I almost didn't upvote this to keep the votes at 9. :D – codedude Nov 7 '13 at 17:55
• (Side note) would you believe I created this image with HTML & CSS as I couldn't be bothered opening up GIMP? – azz Nov 8 '13 at 13:33
• don't worry I do that all the time :) – codedude Nov 9 '13 at 2:08

There is many ways to do it. The real question is: how many? I wonder does the last in this picture counts?

• To stay on the sensible (materially possible) side, I would propose that pens should be either disjoint or fully included in a larger one (intersection or any two pen is either empty or the smaller pen). That would exclude the last one (and the next to last has a pen with six pigs and should also be excluded). Now the problem begins to be interresting. Looks like a Lisp parenthesing problem. – kriss Nov 7 '13 at 12:50
• @kriss Thx, next to last was wrong indeed (also the second one), counting to five is hard! Fixed it and also colored the pens for more clearity. – swish Nov 7 '13 at 13:50

I think I finally got the teachers intended solution ;)

A pen is a closed fence, and since the earth is spherical there is no preferred side of the fence which is the enclosed one. Solution: Put 9 pigs anywhere, put 4 separate pens beside them.

• brilliant! Solution in spherical geometry. – kriss Nov 12 '13 at 12:44
• This works even with a single pig. – Miguel Angelo May 28 '16 at 21:36

Here are 88 solutions (I believe this is all of them):

[2,[2,[4,[1]]]]
[4,[2,[2,[1]]]]
[2,[1]],[3],[3]
[1],[[3]],[5]
[4,[[2,[3]]]]
[[6,[[3]]]]
[6,[1,[1],[1]]]
[2,[[[7]]]]
[1],[3],[4,[1]]
[[3]],[3],[3]
[2,[1],[1],[5]]
[2,[4,[2,[1]]]]
[1,[2,[1]],[5]]
[1],[3],[[5]]
[1,[3],[4,[1]]]
[[4,[4,[1]]]]
[1,[[3]],[5]]
[2,[5,[1],[1]]]
[7,[[1]],[1]]
[4,[[[5]]]]
[5,[1],[[3]]]
[1],[1],[6,[1]]
[[8,[[1]]]]
[1,[1],[[7]]]
[[2,[6,[1]]]]
[[[2,[7]]]]
[6,[1],[1],[1]]
[[1]],[3],[5]
[1,[3],[2,[3]]]
[3,[1],[2,[3]]]
[[2,[[7]]]]
[[4,[[5]]]]
[[6,[2,[1]]]]
[1,[[1]],[7]]
[1],[1],[2,[5]]
[2,[6,[[1]]]]
[1,[1],[4,[3]]]
[2,[[2,[5]]]]
[[3],[3],[3]]
[[[6,[3]]]]
[[[8,[1]]]]
[5,[1],[2,[1]]]
[4,[4,[[1]]]]
[[[4,[5]]]]
[2,[2,[[5]]]]
[1,[1],[2,[5]]]
[1],[1],[4,[3]]
[2,[4,[[3]]]]
[6,[2,[[1]]]]
[[[[9]]]]
[6,[[[3]]]]
[[1,[1],[7]]]
[1],[2,[1]],[5]
[1,[1],[6,[1]]]
[2,[1,[1],[5]]]
[2,[[4,[3]]]]
[8,[[[1]]]]
[4,[3,[1],[1]]]
[1,[3],[[5]]]
[4,[1],[1],[3]]
[[4,[2,[3]]]]
[2,[2,[2,[3]]]]
[[3,[3],[3]]]
[[3,[1],[5]]]
[3,[[3]],[3]]
[3,[1],[[5]]]
[[2,[4,[3]]]]
[2,[1,[3],[3]]]
[[1],[3],[5]]
[2,[[6,[1]]]]
[4,[1,[1],[3]]]
[3,[2,[1]],[3]]
[6,[[2,[1]]]]
[[1],[1],[7]]
[2,[3,[1],[3]]]
[1],[3],[2,[3]]
[[7,[1],[1]]]
[[1,[3],[5]]]
[[5,[1],[3]]]
[[2,[2,[5]]]]
[2,[1],[3],[3]]
[5,[[1]],[3]]
[4,[2,[[3]]]]
[3,[[1]],[5]]
[[1]],[1],[7]
[4,[[4,[1]]]]
[3,[1],[4,[1]]]
[1],[1],[[7]]

• You should supply your code and try to convince us that it produces all possible solutions. – miracle173 Dec 30 '14 at 20:52

Put 9 pigs into 4 pens so that there are an odd number of pigs in each pen.

Each of pens $1,2,3,$ and $4$ have an odd number of pigs in them with $1$ each. The last $5$ pigs are liberally interpreted as being 'put into' the $4$ pens. Though they aren't inside one of the four pens they're inside the four pens.

I didn't see this in the pictured solutions so I thought I'd add it. Apologies if it was already mentioned. It was however mentioned that you could put $1$ in each of the $4$ pens and let the other $5$ roam free. But, what good are your pigs if when you want bacon you discover they walked away? This fixes your bacon in place. Nevertheless, I had fun drawing piggy banks!

Suppose you have 4 pens. An odd number looks like this: $2a + 1$ for some integer $a \ge 0$. Now make for pens and add.

$$2a+1+2b+1+2c+1 +2d+1 = 2(a+b+c+d) + 4 = 2(a+b+c+d+2).$$

The result is even.

• There is no stipulation that an odd integer must also be positive. – Jonathan Landrum Nov 7 '13 at 18:43
• That does not matter here. But if it's being asked of small kids, it's not likely that signed numbers are under discussion. – ncmathsadist Nov 7 '13 at 18:56

Put one in each pen and let the other 5 roam.

No one said they all had to be enclosed in pens when you were done.

• This solution does not "Put 9 pigs into 4 pens" – rybo111 Nov 10 '13 at 12:08

Nobody said the pens were disjoint. With non-disjoint pens, there are many solutions.

• But... are the pigs disjoint? – Bruno Joyal Nov 8 '13 at 22:43
• @BrunoJoyal: if the pigs aren't disjoint, then it's just a matter of time until you have at least 10 pigs, at which time the problem can be solved easily with disjoint pens. – leftaroundabout Nov 10 '13 at 14:06

Just put the pigs in the first pen, then put that pen inside the next pen, etc.

The last pen will contain a pen that contains a pen that contains a pen that contains 9 pigs, but all 4 pens will contain 9 pigs.

You could also put 3 pigs each in 3 pens, and put those 3 pens inside the bigger pen.

The problem as stated is impossible under the usual interpretation, because the sum of four odd numbers will be even, and so can't equal $9$. But the trick question interpretation from Amzoti's comment/answer seems pretty plausible!

Put 6 pigs in the first pen, then 1 pig in each subsequent pen. Don't feed the pigs in the first pen. The first pen will contain an odd number of pigs soon enough.

Another option is to make sure that of the 6 pigs in the first pen, one is the mother, the remainder being piglets and hope for the worst. Same result. That's how pigs get down.

• Horrible, yes. But logically, what's wrong with questioning the mathematical model that pairs integers with pigs? They can indeed literally disintegrate. – minopret Nov 9 '13 at 2:21
• @minopret I suspect that everything was wrong with every facet of this question... – Tonithy Nov 9 '13 at 2:25

Let's rephrase the problem using well defined mathematical terms: as far as I know pigs and pens are not such well defined unambiguous mathematical terms.

Maybe something like:

Dispatch integers from 1 to 9 between 4 sets of integers.

It becomes obvious that it is impossible if sets are disjoint, and trivial if they are not.

And as more "classical" question we could also ask how many ways there is to dispatch these integers between 4 sets where number of items in every set is odd.

• Forgive me for not being knowledgeable in this subject area, but how would one go about proving that it is impossible to do this for disjoint sets? I find this question/riddle/problem intriguing. – iX3 Feb 12 '14 at 7:02
• Would it be similar to Matt E's answer about the sum of 4 odd integers always being even? – iX3 Feb 12 '14 at 7:04
• I call it obvious because I can proove it with a direct enumerative approach. You must put at least 1 pig in each pen because 0 is even, but if you put 1 in the first 3 pens you get 6 in the last one. Now to fix that you must remove at least one pig from the largest pen. 1 won't do (because the pig will make the target pen even, 2 or 4 won't do because the source pen will have an even number of pigs, 3 and 5 similarly won't do if you examine all possible dispatchs. Of course there are other ways to prove it (and generalise it), but the above reasoning is enough. – kriss Feb 12 '14 at 8:21

Just put all the 9 pigs within a pen. Then build a second pen all around the first, a third one all around the second and so on. You will end up by having each pen containing an odd number of pigs.

I assume in elementary school they are not expected to know the parity of zero, so why not this:

3,3,3,0

Thats 9, and all "not even" (again, forget about the parity of zero).

• I don't think it's unreasonable for elementary school students to know the parity of zero. And if they really don't know, how can they be expected to use it in the solution? Not to mention that this solution is just purely wrong. – EuYu Nov 7 '13 at 3:02
• I don't understand all the down votes. In elementary school, I didn't know that 0 was even. I thought it was capable of both, just like from a theoretical point of view, you could have positive zero and negative zero. Didn't know this was such a serious question. No body else took it seriously, especially the "put three pens inside the fourth" answers. That's clearly not the answer either. – Nicholas Yost Nov 7 '13 at 14:15
• It's certainly not an odd number though! – James Nov 7 '13 at 14:19
• @NicholasYost Because you can't use lack of knowledge to prove things. It's like saying "Just make 1 pen with all the pigs in it because I didn't know $1 \neq 4$" – Michael Mrozek Nov 7 '13 at 15:40
• You also can't have positive zero and negative zero. You can put a plus or a minus sign in front of it, but it still just equals zero. Indeed, any reasonable definition of "positive" or "negative" usually boils down to be greater than or less than zero. – Jeremy West Jan 11 '14 at 5:50

## protected by Zev ChonolesNov 8 '13 at 5:12

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).