See Cutting stock problem
In reply to Re: "The Skirting Board Problem" by BrowserUk in thread "The Skirting Board Problem" by loris