Beginner Programmer: Need Help with Problem (Current code is embedded) - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Beginner Programmer: Need Help with Problem (Current code is embedded)

WinklesonWinkleson Posts: 2Member
Hello! I am a beginner programmer in... well programming. Right now I am solving problems on a website and I cannot find a way to solve the entire problem. Any input would be awesome!

Here's The Problem:

Brick Wall
We want to make a row of bricks that is exactly 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.

My current Code:

def make_bricks(small,big,goal):

''' This Function declares whether the size and amount of bricks
are able to achieve the goal of the wall size'''

bigsize = 5
smallsize = 1
bigpot = big*bigsize
smallpot = small*smallsize # I am aware these are not needed as small = smallpot
totalpot = smallpot+bigpot

if (goal < bigsize and goal <= small):
return True
elif ( bigsize == goal and (0 < big or goal <= small)):
return True
elif (bigsize < goal and (bigpot == goal or smallpot == goal)):
return True
elif (totalpot < goal):
return False
else:
pass
----------------------------------------------------------------------

As you can see I don't know how I am able to handle if the goal is a combination of both small and big bricks without a [color=Blue]for()[/color] loop that finds all multiples of bigbricks(5) and add smallbricks (1) to see if a combination can create the goal.... ANy ideas? I would be quite grateful!

-Winkleson
Sign In or Register to comment.