PROBLEM STATEMENT
A certain admin (we won't mention any names, but for the sake of conversation,
we'll call him "lars"), rejected a number of this problem writer's problems.
Define a letter's number to be 1 for a, 2 for b, 3 for c and so on.
The writer immediately noticed a pattern. In all of the rejected ones, there
were at least as many odd letters as even in the problem name. The accepted
ones did not have this property.
Also, all those with length greater than 20 were rejected, and those with
length less than 4 were rejected.
As a third condition, all problems that started with a vowel (A, E, I, O, or U)
were rejected.
Your program should simulate Lars's behavior. It will take a String
representing the problem name, and determine, based on the letters in the name,
whether to accept or reject that problem. If it should be accepted, return the
string "ACCEPT". If it should be rejected because of too many odd letters,
return "ODDLETTERS <odds> <evens>", where odds and evens are the number of odd
letters and even letters, respectively. If it should be rejected because it
is too long, return "TOO LONG <length>" where length is the length of the
string. If it is too short, return "TOO SHORT <length>", in the same fashion.
In no case should you ever have leading zeroes in your numbers. If it begins
with a vowel, return "VOWEL <vowel>" where vowel is the vowel it starts with in
UPPERCASE.
The length rejections override the odd letter rejections and the vowel
rejections, so if there are too many odd letters, but it is 35 characters long
and begins with "a", the return would be "TOO LONG 35".
The vowel rejection overrides the odd letter rejection, so if there are too
many odd letters and it begins with "e", the return would be "VOWEL E". (Note
that it is uppercase.)
DEFINITION
Class Name: Lars
Method Name: acceptOrReject
Parameters: String
Returns: String
Method Signature (be sure your method is public): String acceptOrReject(String
name);
NOTES
-No, this is not really the way Lars accepts or rejects problems.
-All letters in this problem are non case-sensitive, i.e. a has the same value
as A, b has the same value as B, etc. Also, both a and A are vowels, e and E
are vowels, etc.
Topcoder will ensure the validity of the inputs. Inputs are considered valid
if all of the following criteria are met:
-name contains between 0 and 50 characters, inclusive.
-name contains only the characters A-Z, and a-z.
EXAMPLES
1.
name="RSA"
There are two odd letters (A=1, S=19) and one even (R=18).
There are more odd letters than even, so the problem should be rejected.
However, we also notice that the name is too short, it has only 3 characters.
returns "TOO SHORT 3"
2.
name="Temple"
There are three odd letters (e=5, m=13, e=5) and three even letters (T=20,
p=16, l=12).
There are as many odds as evens, and we said all problems that have as many or
more odd letters as even should be rejected, so this one should also be rejected.
returns "ODDLETTERS 3 3"
3.
name="ABCDEF"
This begins with a vowel.
returns "VOWEL A"
4.
name="uIosfjwerd"
Once again it begins with a vowel... but it must be uppercase in the return.
returns "VOWEL U"
5.
name="Philanthropist"
returns "ACCEPT"
6.
name="Antidisestablishmentarianism"
returns "TOO LONG 28"
7.
name=""
returns "TOO SHORT 0"