Statistics

Problem Statement for "Logo"

Problem Statement

PROBLEM STATEMENT

We have designed a logo for our company.  It consists of a pattern of X's. But
the company CEO insists that the logo must be symmetrical.  Create a class Logo
that contains the method symmetric that takes a String[] logo as input and
returns the minimum number of X's that must be added in order to make it
symmetrical.

The CEO will only be satisfied provided that the final version of the logo is
symmetric about some vertical line.

DEFINITION
Class: Logo 
Method: symmetric
Parameters: String[] logo
Returns: int
Method Signature (be sure your method is public): int symmetric(String[] logo);

NOTES
- the final logo may be larger than the original (see the examples below)
- you may only add X's, not remove them

TopCoder will ensure the validity of the inputs.  Inputs are valid if all of
the following criteria are met:
- logo contains between 1 and 50 elements
- each element of logo has the same length
- the length of each String in logo is between 1 and 50 inclusive
- each element of logo contains only '-' or 'X' 

EXAMPLES 
(quotes shown for clarity only)

1) {"-XX-X","-X--X"}: return 1

  -XX-X     ==>  -XXXX-
  -X--X          -X--X-

We can achieve symmetry by adding the one X shown above. The axis of symmetry
in the final logo is between the 3rd and 4th columns.
  
2) {"X---X","-----","X----","X--X-"}: return 2

   X---X         X---X---X
   -----   ==>   ---------
   X----         ----X----
   X--X-         -X--X--X-

Here we added four columns to the left of the logo. This is the only way we
can achieve symmetry by adding 2 X's.  The axis of symmetry in the final logo
is through the middle of the 5th column.

3) {"-","X","X","-","-","X"}: return 0

Every logo with just one column is already symmetrical around the vertical line
through its middle.

4) {"----","X---","XX-X"}: return 2

  ----       -------
  X---  ==>  ---X---
  XX-X       X-XXX-X
             
  This is just one of several ways to add 2 X's and achieve symmetry.          

Definition

Class:
Logo
Method:
symmetric
Parameters:
String[]
Returns:
int
Method signature:
int symmetric(String[] param0)
(be sure your method is public)

Constraints

    Examples


      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)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: