The male gametes or sperm cells in humans and other mammals are heterogametic and contain one of two types of sex chromosomes. They are either X or Y. The female gametes or eggs however, contain only the X sex chromosome and are homogametic.
The sperm cell determines the sex of an individual in this case. If a sperm cell containing an X chromosome fertilizes an egg, the resulting zygote will be XX or female. If the sperm cell contains a Y chromosome, then the resulting zygote will be XY or male.
Determine if the sex of the offspring will be male or female based on the X or Y chromosome present in the male's sperm.
If the sperm contains the X chromosome, return "Congratulations! You're going to have a daughter."; If the sperm contains the Y chromosome, return "Congratulations! You're going to have a son.";
Solution:
Map<String, String> genes = {
"XY": "Congratulations! You're going to have a son.",
"XX": "Congratulations! You're going to have a daughter.",
};
String? chromosome_check(String sperm) {
return genes[sperm];
}
String chromosome_check(String sperm) => "Congratulations! You're going to have a ${sperm == 'XX' ? 'daughter' : 'son'}.";
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1122. Grasshopper - Messi goals function (0) | 2022.11.22 |
---|---|
1121. Grasshopper - Grade book (0) | 2022.11.22 |
1119. Return Negative (0) | 2022.11.19 |
1118. Function 1 - hello world (0) | 2022.11.18 |
1117. Reverse List Order (0) | 2022.11.17 |