Code Help and Videos >
MakeBricks is a favorite CodingBat problem I created for CodingBat. It's deeper than it appears at first. I've received lots of baffled email about this problem over the years, so here I'll try to walk through how to think about it.
See also: MakeBricks Solution Code , Mod Introduction
Here's the original problem statement: We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return true if it is possible to make the goal by choosing from the given bricks. This is a little harder than it looks and can be done without any loops.
Here's the live MakeBricks and the slightly more difficult MakeChocolate problems:
(in python: make_bricks make_chocolate )
Try the link above to give it a try.
CodingBat.com code practice. Copyright 2013 Nick Parlante.