Monday 10 June 2013

Python Puzzles: PART - 1

  The following Python Puzzle is taken from the Programming Practice site CodingBat. I have written about CodingBat in the previous post.

The Puzzle is given below.

We have to make a row of bricks that is goal inches long. There are 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. You should not use any loops.

The function make_bricks( ) is called as follows,
make_bricks(small, large, goal) : Here small is the number of small bricks, large is the number of large bricks and goal is the length of the row to be constructed.

The Figure Below Shows a Sample Output

No comments:

Post a Comment