We are building a rectangular house using manufactured sections for the walls. Each section is 4 feet long. There are three types of sections: window sections, door sections, and regular sections. We have a fixed assortment of these sections, and want to design the house to have a maximum area, subject to the following rules:
1) A house side must contain no more than one door.
2) The house must have at least one door.
3) A door section may not be at the end of a wall.
4) Each window section must be adjacent to two regular sections, one on each side of it in its wall.
Create a class HouseParty that contains a method maxArea that is given numReg, numWin, and numDoor (the available quantity of each type of section) and that returns the maximum area of a house built from those sections. You are not required to use all the sections. If no house can be built your method should return 0.
int, int, int
int maxArea(int numReg, int numWin, int numDoor)
(be sure your method is public)
numReg, numWin, and numDoor will each be between 0 and 50 inclusive.
No house can be built since you have no door sections.
One way is to use 3 regular sections for the north wall, one regular section for the east wall and one for the west wall, and to use a door section between 2 regular sections for the south wall. This gives a house that is 12' x 4'. Below is a picture (with door and window sections shown as D and W, and regular sections shown as - or | )
One design is:
We are very short of regular sections; one design is:
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.