You have recently accepted a job offer at a Pretty Good Software Company. You're pretty content with the size of your office, but do you have the biggest office? Its kinda hard to tell from just eyeballing your co-workers' offices when you stop by. The only way to figure this out is to examine the blueprints for the building...
Write a program, script, or function that takes a floor plan for your building and indicates whether your office is the largest. The floor plan is easy to read because the building is an n by n square.
The input will consist of n+1
\n-delimited lines. The first line will have the number n on it. The next n lines will be the floorplan for the building. A simple example input:
6 ...... . . . .X . . . . . . . . ......
The rules for the floorplan are as follows:
.(ASCII 46) Will be used to represent walls.
(Space [ASCII 32]) will be used to represent open space.
- You are represented by an
X(ASCII 88). You are in your office.
- The floorplan will be n lines, each with n characters.
- The building is totally surrounded by walls on all sides. This implies that the 2nd line of input (the first line of the floorplan) and the last line of input will be all
.s. It also implies that the first and last characters of every floorplan line will be
- An office size is defined as the sum of adjacent spaces (contiguous by moving in 4 directions, N, S, E, W, without going through a wall).
- For the purpose of office size, the X representing you counts as a
- 4 <= n <= 80
You should output whether or not your office is strictly bigger than all the other offices. The output can be anything that unambiguously signifies True or False in your programming language of choice and adheres to standard conventions of zero, null, and empty signifying False. True implies your office is strictly the biggest.
Sample output for above input:
Because your office is 8 square feet, and the only other office is 4 square feet.
- The input may be read from stdin, and answer output to stdout.
- The input may be a single string argument to a function, and answer be the return value of that function.
- The entire building consists of walls and offices.
- The building is only one floor
- There is guaranteed to be an X in the input, but there are not guaranteed to be any spaces. You could have a 1x1 office and the rest of the building is walls (You have the biggest office! hooray!).
10 .......... . . . . . . . . . . . . . .. . . .. . .......... . X . . . ..........
Here there are 3 offices, your south office is rectangular, the northwest office is a triangle(ish) and the northeast office is strangely misshapen, yet bigger than yours. The output should be False.
This is a challenge to write the shortest code, happy code-golfing!