Your lab has been doing a series of tests to a population of adults and children that may or may not be related. Things were going OK until the family data was lost. The family data contained information about which adults were the parents of which children, and which female adults were the spouses of which male adults.
However, the lab still has the genetic profile for each person, along with personality test results for all the adults. Using this information, the lab was able to produce the following three tables, each given as a String:
- femaleGeneticTest: The j-th character of the i-th element of femaleGeneticTest is 'Y' if the i-th female adult is genetically compatible with the j-th child. Otherwise, it is 'N'.
- maleGeneticTest: The j-th character of the i-th element of maleGeneticTest is 'Y' if the i-th male adult is genetically compatible with the j-th child. Otherwise, it is 'N'.
- personalityTest: The j-th character of the i-th element of personalityTest is 'Y' if the personality of the i-th male adult is compatible with the personality of the j-th female adult.
Your task is to try to rebuild the family data from these tables. The lab has defined a family as one female adult and one male adult whose personalities are compatible, along with 0 or more children, each of which is genetically compatible with both adults. Given the information above, return the size of the largest possible family, or return 0 if there are no families.
|Parameters:||String, String, String|
|Method signature:||int getFamily(String femaleGeneticTest, String maleGeneticTest, String personalityTest)|
|(be sure your method is public)|
|-||The input will represent data for F females, M males and C children, with F, M and C being between 1 and 50, inclusive.|
|-||femaleGeneticTest will contain exactly F elements.|
|-||maleGeneticTest will contain exactly M elements.|
|-||personalityTest will contain exactly M elements.|
|-||Each element of femaleGeneticTest will contain exactly C characters.|
|-||Each element of maleGeneticTest will contain exactly C characters.|
|-||Each element of personalityTest will contain exactly F characters.|
|-||Each character of femaleGeneticTest will be 'Y' or 'N'.|
|-||Each character of maleGeneticTest will be 'Y' or 'N'.|
|-||Each character of personalityTest will be 'Y' or 'N'.|
|There is one female adult, one male adult and three kids. The adults' personalities are compatible, so they could be a couple. However, only kid 2 could be their child because he is the only child genetically compatible with both adults.|
|In this case, there are two possible couples (male 0 with female 0 and male 1 with female 1) and 5 children. Only one child is genetically compatible with both members of couple 0, while four children are genetically compatible with couple 1. The largest possible family contains 6 members, composed of male adult 1, female adult 1 and kids 0 to 3.|
|There are four females, three males and nine children. All children are genetically compatible with every adult. However, no two adults of opposite sex have compatible personalities. This means no families can be formed, so the answer is 0.|
|A single couple with no children is considered to be a valid family.|