TopCoder problem "HowManyBirthdays" used in TCHS SRM 30 (Division I Level One)



Problem Statement

    

You have several friends and you want to know which of them are celebrating their birthdays today. You are given a String[] friends, each element of which is formatted as "NAME DAY MONTH" (quotes for clarity), where NAME is a friend's name, and DAY and MONTH are integers representing the day and month, respectively, of that friend's birthday. Today's date is given in the String today, formatted as "DAY MONTH" (quotes for clarity). Return a String[] containing the names of all your friends who have birthdays today, sorted in alphabetical order. If none of your friends have a birthday today, return an empty String[].

 

Definition

    
Class:HowManyBirthdays
Method:getList
Parameters:String[], String
Returns:String[]
Method signature:String[] getList(String[] friends, String today)
(be sure your method is public)
    
 

Notes

-In this problem, all months have exactly 31 days.
 

Constraints

-friends will contain between 1 and 50 elements, inclusive.
-Each element of friends will be formatted as "NAME DAY MONTH" (quotes for clarity).
-today will be formatted as "DAY MONTH" (quotes for clarity).
-In each element of friends, NAME will contain between 1 and 20 lowercase letters ('a'-'z'), inclusive.
-Each DAY in friends and today will be an integer between 1 and 31, inclusive, with no leading zeroes.
-Each MONTH in friends and today will be an integer between 1 and 12, inclusive, with no leading zeroes.
-No two elements of friends will contain the same NAMEs.
 

Examples

0)
    
{"igor 13 6"}
"14 6"
Returns: { }
You have only one friend and he celebrated his birthday yesterday. So, your method should return an empty String[].
1)
    
{"sasha 12 5"}
"12 5"
Returns: {"sasha" }
sasha celebrates his birthday today, so your method should return {"sasha"}.
2)
    
{"larisa 27 3", "kira 7 4", "max 12 3", "kirill 27 3"}
"27 3"
Returns: {"kirill", "larisa" }
3)
    
{"zoro 31 2", "pokemon 16 12", "spiderman 31 12", "dragon 13 7", "elf 31 12"}
"31 12"
Returns: {"elf", "spiderman" }
4)
    
{"ann 6 6", "tanya 6 6", "gudi 6 6", "ruslik 6 6", "alla 6 6", "serge 10 10"}
"6 6"
Returns: {"alla", "ann", "gudi", "ruslik", "tanya" }
5)
    
{"ahdjakdd 31 12", "fhdfjha 1 1", "wefhjks 13 6", "fkajahsdaaajj 6 7"}
"5 12"
Returns: { }

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=7429

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=10654&pm=7429

Writer:

DStepanenko

Testers:

PabloGilberto , brett1479 , Olexiy

Problem categories:

Simulation