I enjoyed giving out these problems when I taught computer science. Read the answer to each one before solving the next one.
How many posts do you need if you want to build a 10-yard long fence, with a post every yard?
11. One at the beginning of each of the 10 yards, and one at the end. (Or nine internal posts with two at the ends.) This leads to lots of problems known in math and computer science as “fence post problems.” E.g., if you have some loop repeat while a counter counts from 0 to 10, the loop will occur 11 times, etc.
How many posts do you need if you want to build a square pen, 10 yards on a side, with a post every yard?
40. You can think of it as nine internal posts per side, for a total of 36, plus the four corners. Or you can use the above question to realize you need 11 per side, for a total of 44, with four of them (at the corners) double counted. Or…
How many posts do you need if you want to build a circular pen with a circumference of 40 yards, with a post every yard?
40. There’s no fence post problem here, since we don’t have an “end” to worry about. So it’s just a post every yard for 40 yards. But note that this is the exact same problem as the one above. If you have a 40 yard loop with a post every yard, it doesn’t matter whether it’s a circle, a square, or a dodecagon. So the alternative way to solve the above problem is to simply ignore the concept of “sides” and think of it as a square.
Comments are closed.