Ask Question
28 November, 18:18

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.

+2
Answers (1)
  1. 28 November, 20:30
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers