Statistics

Problem Statement for "AqaAsadiNames"

Problem Statement

This problem is about a traditional way of naming the second child in a family. Aqa Asadi wants to name his second child this way.

All people in this problem have exactly two names, e.g., “Yasaman Sadat” or “Mohammad Reza”. In this problem, we will assume that the people whose first name starts with a vowel are female and all other people are male. Note that in this problem the letter Y is considered a vowel (so the vowels are A, E, I, O, U, and Y).

You are given the Strings Dad, Mom and FirstChild: the names of a dad, a mom, and their first child. You are also given the String Gender: the gender of their second child (either "Boy" or "Girl"). Your task is to determine and return the name for the second child according to the rules given below.

  • If the gender of the first child differs from the second child, the second child will use both names of their parent with the same gender, in reversed order.
  • If both children have the same gender, the second child will get its first name from the parent with the same gender as itself (i.e., girls from their mom, boys from their dad) and its second name from its older sibling.

Definition

Class:
AqaAsadiNames
Method:
getName
Parameters:
String, String, String, String
Returns:
String
Method signature:
String getName(String Dad, String Mom, String FirstChild, String Gender)
(be sure your method is public)

Notes

  • You should always follow the rules in the problem statement, even if the name they produce does not match the child's gender (see Example #1) or produces the same name as the first child had (see Example #4).

Constraints

  • Each name (Dad, Mom, FirstChild) will contain at most 20 characters.
  • Each name will have the form "First Second", with exactly one space and with exactly the first letter of each name in uppercase.
  • Each name will only consist of uppercase and lowercase English letters (A-Z, a-z), and the single space between the two names.
  • Dad will start with a consonant and Mom will start with a vowel (AEIOUY).
  • Gender will be either "Boy" or "Girl".

Examples

  1. "Mohammad Reza"

    "Yasaman Sadat"

    "Baqer Ali"

    "Boy"

    Returns: "Mohammad Ali"

    Both children are boys, so the second child gets his first name ("Mohammad") from his father and his second name ("Ali") from his brother.

  2. "Mohammad Reza"

    "Yasaman Sadat"

    "Baqer Ali"

    "Girl"

    Returns: "Sadat Yasaman"

    The children have different genders. Thus, the second child's name is obtained by swapping her mother's two names. Note that the returned name is not a proper name for a girl, but that's what the rules produced, so that's what you should return.

  3. "Mohammad Reza"

    "Yasaman Sadat"

    "Umi Kulsum"

    "Girl"

    Returns: "Yasaman Kulsum"

    A case similar to Example #0, but this time the child gets her name by combining the names of her mother and her sister.

  4. "Mohammad Reza"

    "Yasaman Sadat"

    "Umi Kulsum"

    "Boy"

    Returns: "Reza Mohammad"

  5. "X Y"

    "Y X"

    "P T"

    "Girl"

    Returns: "X Y"

  6. "Mohammad Ali"

    "Yasaman Sadat"

    "Mohammad Reza"

    "Boy"

    Returns: "Mohammad Reza"

  7. "Dhikrullah Ali"

    "Umi Kulsum"

    "Reza Hosseinzadeh"

    "Boy"

    Returns: "Dhikrullah Hosseinzadeh"

    Note that the second child's name can sometimes have more than 20 characters.

  8. "Safar Ali"

    "O B"

    "Safar Ali"

    "Boy"

    Returns: "Safar Ali"

  9. "Safar Ali"

    "O B"

    "Safar Ali"

    "Girl"

    Returns: "B O"

  10. "B O"

    "O B"

    "B B"

    "Boy"

    Returns: "B B"

  11. "B O"

    "O B"

    "B B"

    "Girl"

    Returns: "B O"

  12. "Tz Ts"

    "Agciotaepr Xbrfqueds"

    "Owjclyhwk Nrmeguvn"

    "Boy"

    Returns: "Ts Tz"

  13. "Snu Dggmy"

    "Yhrbmf T"

    "Zb Hgojdtfnzxjkayjl"

    "Girl"

    Returns: "T Yhrbmf"

  14. "R Z"

    "Opkdmelxiyj Ro"

    "Ikpmmvaxqcpti Wt"

    "Boy"

    Returns: "Z R"

  15. "Wmybi Q"

    "Aoxkyvgdiup Dyamxty"

    "Q Gogfkgghvubr"

    "Girl"

    Returns: "Dyamxty Aoxkyvgdiup"

  16. "Lyymvhdtbqyax B"

    "Iaykusy Vdgccw"

    "Orckf Fn"

    "Boy"

    Returns: "B Lyymvhdtbqyax"

  17. "Mkbxiahaosfy Clumgn"

    "Oljumpl Xknibx"

    "Ef Hkygdkqosshpeg"

    "Girl"

    Returns: "Oljumpl Hkygdkqosshpeg"

  18. "Xychyqng Atnv"

    "A Quom"

    "Ps Twkmmodbdno"

    "Girl"

    Returns: "Quom A"

  19. "Vkfulhr Nottvnhrn"

    "Y Hewgregyqkgqxc"

    "Jasx Xyvpbtldzm"

    "Girl"

    Returns: "Hewgregyqkgqxc Y"

  20. "N X"

    "Iucts Rdbed"

    "Zptpno Hlwdu"

    "Girl"

    Returns: "Rdbed Iucts"

  21. "Mj Jqlrebnu"

    "Aanb Ffkytjdowxog"

    "Fawtbawdlwn Pxpygm"

    "Girl"

    Returns: "Ffkytjdowxog Aanb"

  22. "Rsmze Blyj"

    "Es Afgb"

    "Pxnflmy Dvqgvz"

    "Girl"

    Returns: "Afgb Es"

  23. "Rfp Jsurfwqdaf"

    "Uwspe Xixzgvmgavhi"

    "Etpgeuk Zgmdpofrwg"

    "Boy"

    Returns: "Jsurfwqdaf Rfp"

  24. "J Rp"

    "Ulylfekz S"

    "Wbjxp Evbmqltxmnwox"

    "Boy"

    Returns: "J Evbmqltxmnwox"

  25. "M Dsfubcsxrr"

    "Ixr Lffumtu"

    "Kpemdiwyq Z"

    "Boy"

    Returns: "M Z"

  26. "Jrtshuizjuavv Bblhlu"

    "Uguhtiunitsct Dukjd"

    "Qoeygrgnkw Pay"

    "Girl"

    Returns: "Dukjd Uguhtiunitsct"

  27. "Rdwd U"

    "Yb Lnzxir"

    "P Rtsbrp"

    "Girl"

    Returns: "Lnzxir Yb"

  28. "Cpxohe Smk"

    "Iof Ofyxb"

    "Vykncao Havr"

    "Boy"

    Returns: "Cpxohe Havr"

  29. "R Cy"

    "U Vs"

    "Qr Rdjyqsooj"

    "Boy"

    Returns: "R Rdjyqsooj"

  30. "Xob Ljnd"

    "Ewovxgcnkrg Klz"

    "Oi M"

    "Girl"

    Returns: "Ewovxgcnkrg M"

  31. "Wccwxejjxw Jowdi"

    "E Apfd"

    "Uqmz Dzio"

    "Girl"

    Returns: "E Dzio"

  32. "Dtzmvhs Kkyugkuuxpvt"

    "Okiguaxj Bomib"

    "Rikpmg Hwnjguxewdcc"

    "Boy"

    Returns: "Dtzmvhs Hwnjguxewdcc"

  33. "D Fzxky"

    "Yeg Ngsqnca"

    "Lchuvzsx Xrqj"

    "Girl"

    Returns: "Ngsqnca Yeg"

  34. "Zuchyreyjzjdvqs Bwq"

    "Unhfyl Q"

    "Pli Fbvqgtyo"

    "Boy"

    Returns: "Zuchyreyjzjdvqs Fbvqgtyo"

  35. "G Gdu"

    "Ydaaeonninr Lmnfgtf"

    "O V"

    "Boy"

    Returns: "Gdu G"

  36. "Hsefy Apljaxb"

    "Ibn Tuvyzecpcfg"

    "Rgd Ncncemltttuuxz"

    "Boy"

    Returns: "Hsefy Ncncemltttuuxz"

  37. "S Ehqnrtuwaealwbq"

    "Oeurrcakmbwj Jtj"

    "C A"

    "Girl"

    Returns: "Jtj Oeurrcakmbwj"

  38. "J Qidai"

    "Einelcayefklnk Baj"

    "Pyxt Dyzklaqzkjlbf"

    "Boy"

    Returns: "J Dyzklaqzkjlbf"

  39. "F Flnnbfixbsyvs"

    "A Lssj"

    "Qw Brpono"

    "Girl"

    Returns: "Lssj A"

  40. "Lrmyaskojc Bvbckfsu"

    "Ovyxbkjpiyvcfelb Wiq"

    "X Hqbnuspseu"

    "Girl"

    Returns: "Wiq Ovyxbkjpiyvcfelb"

  41. "Rdo Jnkqv"

    "Atjrrmoy Hiyqjwjsrkw"

    "M Fbvjuuhhuzkxrj"

    "Girl"

    Returns: "Hiyqjwjsrkw Atjrrmoy"

  42. "Mohammad Reza"

    "Yasaman Sadat"

    "Ymi Kulsum"

    "Girl"

    Returns: "Yasaman Kulsum"


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: