Ask 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). 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.

+1
Answers (1)
  1. 6 June, 08:26
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers