## 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;
}

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

if((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;
}

2. public boolean makeBricks(int small, int big, int goal) {
if (goal/5<=big) return(goal%5<=small);
else return (small>=(goal-big*5));
}

3. public boolean makeBricks(int small, int big, int goal) {
return (goal>(big*5) + small) ? false : (goal%5 <= small) ? true : false;
}

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

1. you are very clever

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

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

return false;

6. if(big>=goal/5){
big=goal/5;
}

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

7. while (big*5>goal)
big = big - 1;
return (5*big + small) >= goal;

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

9. if(goal % 5 > small)
{
return false;
}

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

10. public boolean makeBricks(int small, int big, int goal) {
int 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;
}
}

11. public static boolean test(int small,int big,int goal)
{
int s = small*1 + big*5;

if (s >= goal)
{
return true;
}
else
{
return false;
}
}

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

13. public boolean makeBricks(int small, int big, int goal) {
return 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;
}

14. public boolean makeBricks(int small, int big, int goal) {
int 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;
}

15. public boolean makeBricks(int small, int big, int goal) {
if(goal > big*5 + small){
return false;
} else if(goal % 5 > small){
return false;
} else
return true;
}