Set Operations: please check the details below in the description and WAP

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: 
  1. Students who play all the three sports
  2. Students who play both cricket and football but don’t play hockey
  3. Students who play exactly two of the sports
  4. 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
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Comments