CodingBat code practice

## Introduction to MakeBricks

Video

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.

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.

## Practice Code Problems

Here's the live MakeBricks and the slightly more difficult MakeChocolate problems:
makeBricks  makeChocolate

(in python: make_bricks  make_chocolate )

## Why Is This Hard At All? #1

• Have 2 big bricks and 2 little bricks
• Can you make a 7?
• Can you make a 8?
• Notice: need little bricks to hit the length exactly

## Why Is This Hard At All? #2

• Suppose you have 2 big bricks and 10 little bricks
• Can you make a 16?
• Note: use lots of little bricks instead of a big brick

Try the link above to give it a try.

CodingBat.com code practice. Copyright 2013 Nick Parlante.