One mistake that rookie carpenters will often make is to measure for trim molding – baseboard, casing, crown, etc – by the linear foot. Take the casing on a 7’ door, for example. Each leg of the door requires 84” of trim and the header needs 32”. If your house has 16 doors, and each side of the door needs 200” of trim, then that adds up to 533’ 4” (16 x 2 x 200”). And since you can get casing in 16’ boards, you’d need to order 34 boards to get the job done, right?

Not quite. You’d actually need 38 of those 16’ boards. Although each 16’ board can easily fit two 7’ door legs, the remaining 24” should be scrapped, as a splice in a header casing is about as professional as modHmm. And while door casings are relatively easy to measure for, baseboard and crown molding can get trickier.

Photo Credit: oddsock @ flickr

A general rule of thumb – especially for stained wood – is that splices should be avoided at all (reasonable) costs. While it’s unreasonable to expect an extra-long board to be made for rooms longer than 16’, there’s no reason to splice a 7’ and 4’ section together. Actually, there is a reason, but that has less to do with materials cost and more to do with a lazy carpenter who estimated incorrectly.

Bring Your Own Code

Your exercise for the day: write a function that calculates the number of boards needed to trim out a house.

  • The input should be a series/array of integers that represent each individual measurement; for example, a single 7’ door would be { 84, 32, 84 }.
  • The output should be the minimum number of boards needed to complete the job
  • The board lengths avaiable can be one of three, with the longer boards prefered when possible:
    • Easy - only 16’ boards
    • Medium - 8’ or 16’
    • Hard - an (additional) array of integers that is an input to the function

For bonus points, have your program print the cuts needed on each board.

Special thanks to the lazy carpenter that I hired (and all his spliced moldings) for inspiring this BYOC, and to Todd Lewis for encouraging me to finally write it up. If you have your own fun coding exercise, don’t hesitate to contact me!