TopcoderArchiveVisit Topcoder
SRM24 Oct 2001
SRM 38

Word

Problem statement, definition, constraints, and public examples.

Problem Statement

PROBLEM STATEMENT

Implement a class Word with a method getType to determine what special
properties a word has.  For example, some words are the same when flipped
vertically (about a horizontal axis).  Such words contain letters that are
themselves flippable like "BEE", "BIKE", and "DECK".  Other words appear the
same after a rotation of 180 degrees like "MOW" and "SOS".  To visualize this
transformation, imagine writing the word on a chalkboard and viewing the word
while standing on your head (or equivalently, turning the chalkboard and
viewing it).

DEFINITION
Class Name: Word
Method Name: getType
Parameters: String
Returns: int
Method signature (be sure your method is public): int getType(String word);

String word contains only capital letters with 1-50 characters, inclusive.
This will be checked.

Return value:
3 - Word is the same when flipped vertically or when rotated 180 degrees.
2 - Word is the same when flipped vertically, but not when rotated.
1 - Word is the same when rotated 180 degrees, but not when flipped.
0 - any other case.

For clarity, the following letters are the same after flipping:

flippable = "BCDEHIKOX";

The following letters are the same after a rotation:

rotatable = "HINOSXZ";

Finally, one special case: 'M' becomes 'W' when rotated or flipped and visa
versa.

EXAMPLES
- if word = "SOON", getType should return 0 (no special properties)
- if word = "SOS", getType should return 1 (rotatable only)
- if word = "CODE", getType should return 2 (flippable only)
- if word = "OHO", getType should return 3 (both rotatable and flippable)

Definition

Class:
Word
Method:
getType
Parameters:
String
Returns:
int
Method signature:
int getType(String param0)
(be sure your method is public)

Constraints

    Examples

      No public sample cases were explicitly marked for this problem in the original data.

      Back to all problems