A person has two first names if their last name is also a common first name. You are tasked with determining which full names in a list are two first names.
Any name that occurs in the first name column is potentially a first name. If the number of occurrences of the name in the first name column is greater than the number of occurrences in the last name column, it is definitely a first name.
In the above list,
John appears twice in the first names and once in the last names so it is definitely a first name.
Ryan appears once in the first and once in the last so it is (probably) a first name.
Tom John definitely has two first names and
Luke Ryan probably does.
Given the above list, your code should output the follow:
Luke Ryan has two first names
Tom John definitely has two first names
As mentioned above, your code will take in a list of full names (from standard input, one per line) separated by spaces. Names can include hyphens or apostrophes, but you will never be given a first or last name that includes spaces (ie no
Liam De Rosa, but
Liam De-Rosa or
Liam De'Rosa are fair game. In other words, names will match
Each full name will be unique (ie
John Smith will not appear twice).
Print full names names (once per line) followed by either
has two first names or
definitely has two first names if they meet the criteria above. Names should only be printed once.
Names that are not two first names do not need to be printed.
You must preserve the case and special characters of the name.
Riley Hudson definitely has two first names
Ryan Scott has two first names
Jacob Ella definitely has two first names
Levi Brook has two first names
Notes and Scoring
- This is code golf. Lowest score (bytes) wins.
- standard loopholes apply.