TopcoderArchiveVisit Topcoder
SRM11 May 2006
SRM 302

NounReform

Problem statement, definition, constraints, and public examples.

Problem Statement

In the English language, the plural form of a noun is created according to many difficult rules, but for the most part, a noun can be transformed into its plural form using four simple rules. These rules are:

  1. If the word ends in 's', 'z', 'x', 'ch' or 'sh', add 'es' to the end of the word;
  2. If the word ends in 'ay', 'ey', 'iy', 'oy' or 'uy', add 's' to the end of the word;
  3. If the word ends in 'y', but doesn't satisfy the previous rule, replace the trailing 'y' with 'ies';
  4. In all other cases, just add 's' to the end of the word.

You will be given a String[] nouns. Transform each element of nouns into its plural form using the rules above and return the resulting String[].

Definition

Class:
NounReform
Method:
makePlural
Parameters:
String[]
Returns:
String[]
Method signature:
String[] makePlural(String[] nouns)
(be sure your method is public)

Constraints

  • nouns will contain between 1 and 50 elements, inclusive.
  • Each element of nouns will contain between 1 and 20 characters, inclusive.
  • Each element of nouns will consist of only lower-case letters ('a'-'z').

Examples

  1. {"box", "church", "elephant", "stereo"}
    Returns: {"boxes", "churches", "elephants", "stereos" }
  2. {"tray", "key", "enemy", "baby"}
    Returns: {"trays", "keys", "enemies", "babies" }
  3. {"a", "s", "oy", "y", "yy"}
    Returns: {"as", "ses", "oys", "ies", "yies" }
Back to all problems