In a school, there are total 20 students numbered from 1 to 20. You’re given three lists named ‘C’, ‘F’, and ‘H’, representing students who play cricket, football, and hockey, respectively. Based on this information, find out and print the following:
- Students who play all the three sports
- Students who play both cricket and football but don’t play hockey
- Students who play exactly two of the sports
- Students who don’t play any of the three sports
Examples:
Input:
[2, 5, 9, 12, 13, 15, 16, 17, 18, 19]
[2, 4, 5, 6, 7, 9, 13, 16, 20]
[1, 2, 5, 9, 10, 11, 12, 13, 15, 20]
Output:
[2, 5, 9, 13]
[16]
[12, 15, 16, 20]
[3, 8, 14]
Explanation:
1.Given the three sets, you can see that the students numbered '2', '5', '9', and '13' play all the three sports.
2. The student numbered '16' plays cricket and football but doesn't play hockey.
3. The students numbered '12' and '15' play cricket and hockey, the student numbered '16' plays cricket and football and the student numbered '20' plays football and hockey. Hence, the students who play exactly two sports are 12, 15, 16, and 20.
4. As you can see, the students who play none of the sports are 3, 8, and 14.
Published By : Vaibhav G. Khetal