Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID


We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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

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!

Sign In or Register to comment.