As you finish the last group’s customs declaration, you notice that you misread one word in the instructions.
You don’t need to identify the questions to which anyone answered “yes”; you need to identify the questions to which everyone answered “yes”!
Using the same example as above:
abc
a
b
c
ab
ac
a
a
a
a
b
This list represents answers from five groups:
3 questions: a, b, and c.1 question, a. Since some people did not answer “yes” to b or c, they don’t count.1 question, a.1 question, b.In this example, the sum of these counts is 3 + 0 + 1 + 1 + 1 = 6.
For each group, count the number of questions to which everyone answered “yes”. What is the sum of those counts? Determine this in the following way:
groupCount that takes the “yes” answers (String) of one group. The answers from each person in the group are separated by spaces. The function must return the number (Int) of questions to which everyone in the group answered “yes”.planeCount that takes the pathname (String) of a text file that collects the “yes” answers from every group on the plane. The function must return the sum (Int) of the number of questions to which everyone in the group answered “yes”.In this interactive session we assume the text file forms.txt1 to be located in the current directory.
> groupCount "abc"
3
> groupCount "a b c"
0
> groupCount "ab ac"
1
> groupCount "a a a a"
1
> groupCount "b"
1
> planeCount "forms.txt"
6