Ask Question
31 July, 03:14

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.

+3
Answers (1)
  1. 31 July, 04:46
    0
    Answer and Explanation:

    This is little harder than it looks and can be done without using loops. Lets take Bricks method to make a program.

    Bricks (3,1, 8)

    Bricks (3, 1, 9)

    Bricks (3, 2, 10)

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

    if (goal > big * 5 + small)

    return false;

    if (goal % 5 > small)

    return false:

    }

    OR

    public make_bricks (int small, int big, int goal):

    if (goal % 5) < = big:

    if (goal % 5) < = small:

    return True

    else:

    return False

    if (goal % 5) > = big:

    if (goal - (big*5)) < = small:

    return True

    else:

    return False
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “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). ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers