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.
John Smith
John Doe
Luke Ryan
Ryan Johnson
Jenna Jackson
Tom John
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.
Therefore, 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
Input
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 [-'A-Za-z]+
.
Each full name will be unique (ie John Smith
will not appear twice).
Output
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.
Examples
Input
Madison Harris
Riley Hudson
Addison Hills
Riley Phillips
Scott Hill
Levi Murphy
Hudson Wright
Nathan Baker
Harper Brooks
Chloe Morris
Aubrey Miller
Hudson Lopez
Samuel Owen
Wyatt Victoria
Brooklyn Cox
Nathan Murphy
Ryan Scott
Output
Riley Hudson definitely has two first names
Ryan Scott has two first names
Input
Owen Parker
Daniel Hall
Cameron Hall
Sofia Watson
Mia Murphy
Ryan Jones
Emily Ramirez
Output
[no output]
Input
Olivia Robinson
Jacob van-Dyke
Jacob Ella
Brayden De'Rosa
Levi Brook
Brook Bella
Ella Hill
Ella Anderson
Brook-Anne van-Dyke
Output
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.
Good luck!
Johnson
count asJohn
, or is it different? \$\endgroup\$Johnson
would be different thanJohn
. Names must match exactly. \$\endgroup\$definitely has two first names
andhas two first names
? It can be always one of those? \$\endgroup\$definitely
if the the name occurs more times in the first-name column than the last-name column. This case overrides, so only displaydefinitely has two first names
. Check out the examples. \$\endgroup\$