Statistics

Problem Statement for "Normalizer"

Problem Statement

An online registration system must check that the registrants' user names are unique. The user names are allowed to contain numbers, capital and lowercase letters, and spaces. However, the system must be made so that the normalized forms of all user names are unique.

The normalized form of a user name is the form in which all spaces are removed and all capital letters are converted to lower case.

Thus the user names "username" and "Us Er Na Me" do not have unique normalized forms.

You are to write a class Normalizer which contains a method normalize. The method takes a String that is a user name as a parameter and returns the normalized form of the user name.

Definition

Class:
Normalizer
Method:
normalize
Parameters:
String
Returns:
String
Method signature:
String normalize(String userName)
(be sure your method is public)

Constraints

  • userName contains between 1 and 50 characters, inclusive.
  • userName contains at least 1 non-space character.
  • userName contains lowercase and capital letters, digits, and spaces (a-z, A-Z, 0-9).

Examples

  1. " thIS1201982 Is a TEst"

    Returns: "this1201982isatest"

  2. " K "

    Returns: "k"

  3. " 1 1 1"

    Returns: "111"

  4. " HiHoWaRe YOU"

    Returns: "hihowareyou"

  5. "nochangehere"

    Returns: "nochangehere"

  6. " 11111iiii1111 "

    Returns: "11111iiii1111"

  7. "THISISAREALLYLONGUSERNAME12345678899"

    Returns: "thisisareallylongusername12345678899"

  8. "123456789012345678901234567890123456789"

    Returns: "123456789012345678901234567890123456789"

  9. " l"

    Returns: "l"

  10. "s df ssdf dsf sdf SDFSF SDF SDFSDF SDF DF"

    Returns: "sdfssdfdsfsdfsdfsfsdfsdfsdfsdfdf"

  11. "username"

    Returns: "username"

  12. "Us Er Na Me"

    Returns: "username"

  13. "HI133"

    Returns: "hi133"

  14. " helloOoOo"

    Returns: "hellooooo"

  15. "a"

    Returns: "a"

  16. " 1 "

    Returns: "1"

  17. "a 1 1"

    Returns: "a11"

  18. "AbC 123 aBC 123"

    Returns: "abc123abc123"

  19. "user name"

    Returns: "username"

  20. "Te s t 1 2 3 FFFa1"

    Returns: "test123fffa1"

  21. "a b"

    Returns: "ab"

  22. "numberals 123"

    Returns: "numberals123"

  23. "username"

    Returns: "username"

  24. "Us Er Na Me"

    Returns: "username"

  25. "HI133"

    Returns: "hi133"

  26. " helloOoOo"

    Returns: "hellooooo"

  27. "a"

    Returns: "a"

  28. " 1 "

    Returns: "1"


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: