PROBLEM STATEMENT
A TopCoder member TheBestCoder was the main character of a problem of mine
submitted for Single Round Match 110. My two testers didn't like the handle,
saying that it was too arrogant. We came up with the following list of proposed
handles: {"TheBestCoder", "Phoenix", "TheWorstCoder", "bahahahah", "Fenix"}. We
agreed to vote for a handle using the following protocol:
Each tester sends me the handle he prefers. If they agree on the same handle,
then this handle is chosen. If they disagree, I choose from their two
suggestions which one I like better.
Knowing myself and my sense of humor, I suspect I will find myself in similar
situations fairly often (I'm thinking of a future problem featuring the
TopCoder member EternalGenius ...). Therefore, I would like you to write me a
program that will run this protocol for us whenever we should find ourselves in
need of it. Your task is, given a String[] describing my preferences and two
Strings giving my testers' votes, return the result of the vote. The array of
Strings of my preferences starts with my favorite, and continues to the less
and less desirable handles.
DEFINITION
Class: Handle
Method: vote
Parameters: String[], String, String
Returns: String
Method signature (be sure your method is public): String vote(String[]
myPreferences, String vote1, String vote2);
TopCoder will ensure the validity of the inputs. Inputs are valid if all of the
following criteria are met:
- myPreferences has between 1 and 6 elements inclusive
- each element of myPreferences and vote1 and vote2 has between 1 and 15
characters inclusive
- each element of myPreferences and vote1 and vote2 consists of letters [A-Z]
and [a-z] or digits [0-9] only
- elements of myPreferences are different
- each of vote1 and vote2 is equal to one of the elements of myPreferences
NOTES
- handles are case sensitive, e.g. the handles MasterMind and Mastermind are
different
EXAMPLES
1. myPreferences = {"TheBestCoder", "Phoenix", "TheWorstCoder", "bahahahah",
"Fenix"}, vote1 = "bahahahah", vote2 = "Fenix"; return "bahahahah"
2. myPreferences = {"MurMur", "Spiderman", "AnakinSkywalker", "DarthVader"},
vote1 = "AnakinSkywalker", vote2 = "DarthVader"; return "AnakinSkywalker"
3. myPreferences = {"some1", "someone", "nobody", "everybody"} vote1 =
"nobody", vote2 = "nobody"; return "nobody"