Friday, July 17, 2009

A chicken, a fox, and a bag of grain

You've got a chicken, a fox, and a bag of grain on one side of the river, and a boat that holds you and one of the chicken/fox/grain. If the fox is left alone with the chicken, he'll eat it. If the chicken is left alone with the grain, he'll eat it. How do you get all across the river so that nobody/nothing gets eaten.

Here how the different type of programmers solved that age old riddle.

Oldschool Programmer: Leave the fox with the grain. Take the chicken across the river. Go back and take the fox across. Leave the fox there, bring back the chicken. Then, leave the chicken and take the grain across the river. Leave the grain there and go back to get the chicken.

Newbie Programmer: Leave the fox with the grain or just throw the chicken across the river.

Hardware Programmer: Kill the fox, the fox is no use to the farmer.

Freelance Programmer: BBQ the chicken, blame it on the fox, and claim crop insurance.

Extreme Programmer: let the chicken eat the grain then the fox eat the chicken. Transfer the fox which contain the chicken that contain grain across the river in one crossing.

No comments: