There was a farmer making his way to the market with a fox, a chicken, and some grain. He came to a clearing with a stream. There was a rickety bridge nearby, but he could only take one of his items with him across the bridge at a time. He knew if he took the grain, and left the fox with the chicken, the fox would eat the chicken. If he took the fox, the chicken would eat the grain. How do you get all of them across?
To get all of them across, the farmer can follow these steps:

1. Take the chicken across, then return.
2. Take the fox across, then return with the chicken.
3. Take the grain across, then return.
4. Take the chicken across.

In this way, he would only leave the grain and the fox together and leave the chicken alone, which avoids the problems mentioned.