March 6, 2010

unless the fence is closed, rather than straight


If you build a straight fence one hundred feet long, using ten-foot-long rails, how many fenceposts do you need?

The obvious answer is 100/10=10, which is wrong. The correct answer is eleven.

If you write a computer program to process items I through J of a list, how many items will be processed?

The obvious answer is J-I items, which is wrong. The correct answer is J-I+1.

By analogy to the fencepost question, the wrong answer is known as the "fencepost error".

No comments:

Post a Comment

ShareThis

Blog Archive