**From New Scientist #1553, 26th March 1987** [link]

“What animals have you in that barn there?” said the man from the ministry.

The farmer beamed. “Pigs, cows and ducks, sir.”

“How many are there, though?”

“Oh, quite a few, really, sir.”

“I need figures, man!” persevered the would-be census taker.

“If it’s figures you’ll be wanting, sir,” replied the farmer, “I can tell you that multiplying the number of horns by the number of legs by the number of wings gives 720.”

“Yes, but how many of each animal are there?” snapped the other exasperatedly.

“Telling you the number of cows alone wouldn’t enable you to deduce the number of ducks and pigs. Telling you the number of ducks alone wouldn’t enable you to deduce the number of pigs and cows. But telling you the number of pigs would enable you to deduce the number of cows and ducks right enough. So I reckon you can work out how many cows and ducks there be in yonder barn even if I *don’t* tell you the number of pigs in it.”

With that he ducked into a hen-house.

How many cows, ducks and pigs were there in the barn?

[enigma403]

### Like this:

Like Loading...

I assumed that each cow has 4 legs, 2 horns and no wings, each duck has 2 legs, no horns and 2 wings, each pig has 4 legs, no horns and no wings.

This Python program runs in 39ms.

Solution:There are 2 cows, 1 duck, and 20 pigs.Altogether there are 4 horns (on the cows), 90 legs (8 on the cows, 2 on the duck, 80 on the pigs) and 2 wings (on the duck), giving a product of 720.