# Need help! Why my code is not passing subtask2 and subtask3?

``````for i in range(int(input())):
n = int(input())
s1 = {'cakewalk','simple','easy','easy-medium','medium-hard'}
s2 = {'cakewalk','simple','easy','easy-medium','hard'}
s3 = {'cakewalk','simple','easy','medium','medium-hard'}
s4 = {'cakewalk','simple','easy','medium','hard'}
s6 = {'cakewalk','simple','easy','easy-medium','medium-hard','medium','hard'}
s5 = set()
for j in range(n):
if s5 == s1 or s5 == s2 or s5 == s3 or s5 == s4 or s5 == s6:
print('Yes')
else:
print('No')
``````

Unable to find why your code is failing and this code is passing.

Python Code
``````for i in range(int(input())):
n = int(input())
s1 = {'cakewalk','simple','easy','easy-medium','medium-hard'}
s2 = {'cakewalk','simple','easy','easy-medium','hard'}
s3 = {'cakewalk','simple','easy','medium','medium-hard'}
s4 = {'cakewalk','simple','easy','medium','hard'}
contest_set = set()
for i in range(n):
if contest_set & s1 == s1 or contest_set & s2 == s2 or contest_set & s3 == s3 or contest_set & s4 == s4:
print("Yes")
else:
print("No")
``````
1 Like

thanks for the improvised solution but still I need answer why my code is failing?

Try this test case.

Input:

``````1
7
simple
hard
cakewalk
easy-medium
easy
medium-hard
hard
``````

Expected Output:

``````Yes
``````

``````No
it is enough to check if any one of the sets `(s1, s2, s3, s4, s6)` is a subset of `s5`