Problem Statement
Oliver and Stan have inherited some land in the desert. Having had a falling out, they
need to divide this land in some equitable way.
The land contains some buildings, some garden, and unknown to Oliver, some underground
silver. The pair has agreed to split the land in a way where each gets precisely
half of the gardens and half of the buildings, by area. The property must be split
by a single straight dividing line. Stan wants to find the dividing line that
divides the buildings and gardens exactly in half, and maximizes the area of the
silver-containing portions.
The property is described by a grid of letters given in an array of strings.
Each letter will be either 'B' for building, 'G' for garden, 'S' for silver,
or '.' for empty land. Each letter represents a square of land exactly
20 feet by 20 feet. Find the best dividing line for Stan and return the
area (in square feet) of the silver-containing land on his half.
Definition
- Class:
- PropertySplit
- Method:
- mostSilver
- Parameters:
- String[]
- Returns:
- double
- Method signature:
- double mostSilver(String[] property)
- (be sure your method is public)
Constraints
- property will contain between 1 and 50 elements, inclusive.
- Each element of property will contain the same number of characters.
- Each element of property will contain between 1 and 50 characters.
- Each element of property will consist entirely of 'B', 'G', 'S', and '.' characters.
Examples
No public sample cases were explicitly marked for this problem in the original data.