The farmers boy is going to market again. This time he's taking his faithful dog, two geese,and three bags of corn. He again has to cross the river,but this time he can only carry two items across at a time. He knows if he leaves tham alone, the dog will eat the goose and the goose will eat the corn. How can he get his dog, the two geese, and the three bags of corn across safely without anything getting eaten?

The idea is to isolate the geese from the dog and the corn.

Let
D=dog
G=goose
C=corn
> > or < < crossing river
Initially:
DCCC >GG>
DCCC < < GG
DC >CC> GG
DC <GG< CC
GG >DC> CC
GG < < DCCC
>GG> DCCC

That makes no sense :D

To get the farmer's dog, two geese, and three bags of corn across the river safely without anything being eaten, the farmer needs to use a specific sequence of crossings. Here's how he can achieve that:

1. The farmer takes the two geese across the river and leaves them on the other side.
- Current Situation: Dog and three bags of corn on one side, two geese on the other side.

2. The farmer goes back alone to the original side of the river.
- Current Situation: Dog and three bags of corn on one side, two geese on the other side.

3. The farmer takes the dog across the river and leaves it on the other side, but he brings one goose back to the original side.
- Current Situation: Dog and one goose on one side, two geese and three bags of corn on the other side.

4. The farmer leaves the dog and takes one bag of corn across the river, but he brings the goose back to the original side.
- Current Situation: One bag of corn on one side, Dog and one goose on the other side, two geese and two bags of corn on the original side.

5. The farmer leaves the bag of corn, and this time, he takes the goose across the river.
- Current Situation: One bag of corn and the goose on one side, Dog and one goose on the other side, and one bag of corn on the original side.

6. The farmer leaves the goose on the other side and takes the dog back to the original side.
- Current Situation: One bag of corn and the goose on one side, Dog on the original side, two geese and one bag of corn on the other side.

7. Finally, the farmer takes the remaining two bags of corn across the river.
- Current Situation: One bag of corn and the goose on one side, Dog on the original side, two geese and three bags of corn on the other side.

Now, the farmer has successfully transported the dog, two geese, and three bags of corn across the river without any of them being eaten.