#C14194. Birthday Analyzer
Birthday Analyzer
Birthday Analyzer
You are given a list of people with their names and birthdates. Each birthdate is provided in the format YYYY-MM-DD
. Your task is to write a program that:
- Finds the oldest person among the list.
- Finds the youngest person among the list.
- Groups people by the month of their birth, preserving the input order for each group.
If the input list is empty, the program should output None
for both the oldest and youngest persons and output no month groups.
Note: If multiple people share the same birthdate, the one appearing first in the input is considered older and the one appearing last is considered younger.
The month names should be output in calendar order if there is any person born in that month.
inputFormat
The input is read from standard input (stdin
) and has the following format:
- The first line contains an integer
n
representing the number of people. - The next
n
lines each contain a person's name and their birthdate in the formatName YYYY-MM-DD
, separated by a space.
outputFormat
The output is written to standard output (stdout
) and should be in the following format:
- The first line is the name of the oldest person (or
None
if the list is empty). - The second line is the name of the youngest person (or
None
if the list is empty). - For each month that has at least one person, output a line containing the month name followed by the names of the people born in that month (in the order they appeared in the input), separated by a space. The months should be in chronological order (January, February, ..., December).
4
Alice 1990-05-24
Bob 1985-12-30
Charlie 1992-05-15
David 2000-08-05
Bob
David
May Alice Charlie
August David
December Bob
</p>