Statistics

Problem Statement for "SpellCheck"

Problem Statement

You've been hired by a software company to work on a word processor. The word processor applies a set of simple rules to fix spelling errors, and you must write code for the rule of "I before E except after C." Every instance of "EI" in the text should be changed to "IE" unless the instance immediately follows the letter 'C'. The case of the letters does not affect the rule; the 'i','e', and 'c' can be either upper or lower case. If the application of the rule creates a new "EI" occurence, we apply the rule again, repeating until the rule no longer matches anything in the input data. We never change the case of the letters; "Ei" is changed to "iE" if it is not immediately preceded by a 'C'. Obviously, the rule fixes some spelling errors, and introduces others.

The rule does not affect any "IE" sequence: "cie" is not altered.

The rule would change "freind" to "friend," but would leave "received" alone. "Leonard Berstein" would be changed to "Leonard Berstien." "AEIOU" would get changed to "AIEOU". "eeEI" gets changed to "IeeE." because the rule is applied repeatedly. "ceei" gets changed to "ceie" because the last two letters match the "ei" sequence, and are not immediately preceded by a "c."

Create a class SpellCheck which contains a method IbeforeE that takes a String line and returns a String which holds the text after all applications of the rule.

Definition

Class:
SpellCheck
Method:
IbeforeE
Parameters:
String
Returns:
String
Method signature:
String IbeforeE(String line)
(be sure your method is public)

Constraints

  • line will contain between 0 and 50 characters, inclusive.
  • Each character in line will be a letter ('a'-'z', 'A'-'Z'), a digit ('0'-'9'), or the space character (' ').

Examples

  1. "AEIOU received Ceiling eeeIi"

    Returns: "AIEOU received Ceiling Iieee"

  2. "Let me introduce you to my little freind"

    Returns: "Let me introduce you to my little friend"

  3. "EIEIO And on that farm we have some code"

    Returns: "IIEEO And on that farm we have some code"

  4. "eIeIo ei EI eI Ei cei cEI ceI cEi Cei CEI CEi CeI"

    Returns: "IIeeo ie IE Ie iE cei cEI ceI cEi Cei CEI CEi CeI"

  5. "EiC ice ee ii eieieieiiiiiiiiiii"

    Returns: "iEC ice ee ii iiiiiiiiiiiiiieeee"

  6. "eEeEeEiIiIiIiIceeeeIieiEiE"

    Returns: "iIiIiIiIeEeEeEceIiiieeeeEE"

  7. "eiEiiiiiiiiiiiiiiiiiiiiiiiIIIiiiiiiiiiiiiiiiiiIIii"

    Returns: "iiiiiiiiiiiiiiiiiiiiiiiiIIIiiiiiiiiiiiiiiiiiIIiieE"

  8. "eeeeeEEEEEeeeeeEEEEEeeeeeIIIIIiiiiiIIIIIiiiiiIIIII"

    Returns: "IIIIIiiiiiIIIIIiiiiiIIIIIeeeeeEEEEEeeeeeEEEEEeeeee"

  9. "This is a TEST IECE CEI lksdfjalksd"

    Returns: "This is a TEST IECE CEI lksdfjalksd"

  10. ""

    Returns: ""

  11. "ei"

    Returns: "ie"

  12. "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeI"

    Returns: "Ieeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"

  13. " ie ei"

    Returns: " ie ie"

  14. "I before E except after C"

    Returns: "I before E except after C"

  15. "as an A as in Neighbor and Weigh"

    Returns: "as an A as in Nieghbor and Wiegh"

  16. "Cie eic clie eilfjsldfs"

    Returns: "Cie iec clie ielfjsldfs"

  17. "cieeieicieieiceieiccieciecieiieeceieiceiieieieicie"

    Returns: "ciiieeeciiieeceiiecciecieciiieeeceiieceiiiiieeecie"

  18. "aBFdc ieeeeIhhh eIIEeeEieicIe"

    Returns: "aBFdc iIeeeehhh IIiieEeeEecIe"

  19. "eiiiiiiiiiiiiiiiii"

    Returns: "iiiiiiiiiiiiiiiiie"

  20. "AEIOU received Ceiling eeeIi"

    Returns: "AIEOU received Ceiling Iieee"

  21. "ei"

    Returns: "ie"

  22. "CeiCie"

    Returns: "CeiCie"

  23. "cei"

    Returns: "cei"

  24. "CIELING"

    Returns: "CIELING"

  25. "cie"

    Returns: "cie"

  26. "receive"

    Returns: "receive"

  27. "dCeideeiCeidceiidddeiiieceidddeeeecdeiieieeee"

    Returns: "dCeidieeCeidceiidddiiieeceidddeeeecdiiieeeeee"

  28. "EiceiCeiCEIeiiieeieiceIeIeICeiieeiieeeI"

    Returns: "iEceiCeiCEIiiiiieeeeceIIIeeCeiiiiIeeeee"

  29. "eiiiiiiiiiiiiiiiiiii"

    Returns: "iiiiiiiiiiiiiiiiiiie"

  30. "eeii"

    Returns: "iiee"

  31. "eeeIi EIEIO freind eei ceei ceeii ececiie "

    Returns: "Iieee IIEEO friend iee ceie ceiie ececiie "

  32. "eeEI"

    Returns: "IeeE"

  33. "ceeiieei"

    Returns: "ceiiieee"

  34. "AIEOU received Ceiling Iieee"

    Returns: "AIEOU received Ceiling Iieee"

  35. "cieeieicieieiceieiccieciecieiieeceieiceiieieieicie"

    Returns: "ciiieeeciiieeceiiecciecieciiieeeceiieceiiiiieeecie"

  36. "aBFdc ieeeeIhhh eIIEeeEieicIe"

    Returns: "aBFdc iIeeeehhh IIiieEeeEecIe"

  37. "eiiiiiiiiiiiiiiiii"

    Returns: "iiiiiiiiiiiiiiiiie"

  38. "AEIOU received Ceiling eeeIi"

    Returns: "AIEOU received Ceiling Iieee"

  39. "ei"

    Returns: "ie"

  40. "CeiCie"

    Returns: "CeiCie"

  41. "cei"

    Returns: "cei"

  42. "CIELING"

    Returns: "CIELING"

  43. "cie"

    Returns: "cie"

  44. "receive"

    Returns: "receive"

  45. "dCeideeiCeidceiidddeiiieceidddeeeecdeiieieeee"

    Returns: "dCeidieeCeidceiidddiiieeceidddeeeecdiiieeeeee"

  46. "EiceiCeiCEIeiiieeieiceIeIeICeiieeiieeeI"

    Returns: "iEceiCeiCEIiiiiieeeeceIIIeeCeiiiiIeeeee"

  47. "eiiiiiiiiiiiiiiiiiii"

    Returns: "iiiiiiiiiiiiiiiiiiie"

  48. "eeii"

    Returns: "iiee"

  49. "eeeIi EIEIO freind eei ceei ceeii ececiie "

    Returns: "Iieee IIEEO friend iee ceie ceiie ececiie "

  50. "eeEI"

    Returns: "IeeE"

  51. "ceeiieei"

    Returns: "ceiiieee"

  52. "AIEOU received Ceiling Iieee"

    Returns: "AIEOU received Ceiling Iieee"

  53. "cieeieicieieiceieiccieciecieiieeceieiceiieieieicie"

    Returns: "ciiieeeciiieeceiiecciecieciiieeeceiieceiiiiieeecie"

  54. "aBFdc ieeeeIhhh eIIEeeEieicIe"

    Returns: "aBFdc iIeeeehhh IIiieEeeEecIe"

  55. "eiiiiiiiiiiiiiiiii"

    Returns: "iiiiiiiiiiiiiiiiie"

  56. "AEIOU received Ceiling eeeIi"

    Returns: "AIEOU received Ceiling Iieee"

  57. "ei"

    Returns: "ie"

  58. "CeiCie"

    Returns: "CeiCie"

  59. "cei"

    Returns: "cei"

  60. "CIELING"

    Returns: "CIELING"

  61. "cie"

    Returns: "cie"

  62. "receive"

    Returns: "receive"

  63. "dCeideeiCeidceiidddeiiieceidddeeeecdeiieieeee"

    Returns: "dCeidieeCeidceiidddiiieeceidddeeeecdiiieeeeee"

  64. "EiceiCeiCEIeiiieeieiceIeIeICeiieeiieeeI"

    Returns: "iEceiCeiCEIiiiiieeeeceIIIeeCeiiiiIeeeee"

  65. "eiiiiiiiiiiiiiiiiiii"

    Returns: "iiiiiiiiiiiiiiiiiiie"

  66. "eeii"

    Returns: "iiee"

  67. "eeeIi EIEIO freind eei ceei ceeii ececiie "

    Returns: "Iieee IIEEO friend iee ceie ceiie ececiie "

  68. "eeEI"

    Returns: "IeeE"

  69. "ceeiieei"

    Returns: "ceiiieee"

  70. "AIEOU received Ceiling Iieee"

    Returns: "AIEOU received Ceiling Iieee"


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: