##
**Problem:**

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. See also: Introduction to MakeBricks

makeBricks(3, 1, 8) → true

makeBricks(3, 1, 9) → false

makeBricks(3, 2, 10) → true

##
**Solution:**

public boolean makeBricks(int small, int big, int goal) { int digit = goal % 10; if (goal > small + (big * 5)) return false; if (digit < 5 && small < digit) return false; else if (digit > 5 && digit > small + 5) return false; else return true; }

public boolean makeBricks(int small, int big, int goal) {

ReplyDeleteif((big*5)>goal) goal%=5; //Too many 'big' bricks.

else goal-=(5*big); //If not too many big bricks, then sub. what you have.

if(small>=goal) return true;

return false;

}

public boolean makeBricks(int small, int big, int goal) {

ReplyDeleteif (goal/5<=big) return(goal%5<=small);

else return (small>=(goal-big*5));

}

public boolean makeBricks(int small, int big, int goal) {

ReplyDeletereturn (goal>(big*5) + small) ? false : (goal%5 <= small) ? true : false;

}

return goal % 5 <= small && big * 5 + small >= goal;

ReplyDeleteyou are very clever

DeleteEGYESBLOG - What an intelligent logic. How can i work on my skills to be able to think like that?

Deleteif ((goal/5 >=big) &&(goal-big*5)<=small) return true;

ReplyDeleteif ((goal/5 < big)&&(goal-goal/5*5<=small))return true;

return false;

if(big>=goal/5){

ReplyDeletebig=goal/5;

}

return (big*5)+small>=goal;

while (big*5>goal)

ReplyDeletebig = big - 1;

return (5*big + small) >= goal;

return (small+5*big>=goal&&small>=goal%5);

ReplyDeleteif(goal % 5 > small)

ReplyDelete{

return false;

}

return small + (big * 5) >= goal;

public boolean makeBricks(int small, int big, int goal) {

ReplyDeleteint val = 0;

if(goal>=big*5){

val = goal - big*5;

}

else if ((goal/5)<=big){

val = goal- (goal/5)*5;

}

if(small>=val){

return true;

}

else{

return false;

}

}

public static boolean test(int small,int big,int goal)

ReplyDelete{

int s = small*1 + big*5;

if (s >= goal)

{

return true;

}

else

{

return false;

}

}

return (goal/5<=big&& goal%5<=small)||(goal-big*5>0&& goal-big*5<=small);

ReplyDeletepublic boolean makeBricks(int small, int big, int goal) {

ReplyDeletereturn goal % 5 <= small && big * 5 + small >= goal;

//return (small+5*big>=goal&&small>=goal%5);

//return (goal/5<=big&& goal%5<=small)||(goal-big*5>0&& goal-big*5<=small);

//return (small+5*big>=goal&&small>=goal%5);

//return goal % 5 <= small && big * 5 + small >= goal;

//return (goal>(big*5) + small) ? false : (goal%5 <= small) ? true : false;

}

public boolean makeBricks(int small, int big, int goal) {

ReplyDeleteint total = big*5 + small;

int div = goal/5;

int sub = goal - div*5;

if(goal<=total){

if(sub<=small){

return true;

}

return false;

}

return false;

}

public boolean makeBricks(int small, int big, int goal) {

ReplyDeleteif(goal > big*5 + small){

return false;

} else if(goal % 5 > small){

return false;

} else

return true;

}