May Starters Test Cases

In the May Starters 2021 there was the question CORRECT SENTENCE and the logic I used is a little different from the editorial so I was thinking if the test cases used while checking the code could be shared so that I can see where I lacked…plz see to it

Share your code

t=int(input())
for case in range(t):
k,s=map(str,input().split(maxsplit=1))
s=s.split()
k=int(k)
lc=[“a”,“b”,“c”,“d”,“e”,“f”,“g”,“h”,“i”,“j”,“k”,“l”,“m”]
upc=[“N”,“O”,“P”,“Q”,“R”,“S”,“T”,“U”,“V”,“W”,“X”,“Y”,“Z”]
up=0
low=0
c=0
for i in range(0,k):
if ((s[i].isupper()==False) and (s[i].islower()==False)):
c=-1
break
elif (s[i].isupper()==True):
for letter in s[i]:
if letter not in upc:
c=-1
break
else:
up=up+1
elif (s[i].islower()==True):
for let in s[i]:
if let not in lc:
c=-1
break
else:
low=low+1
if (up==0) or (low==0) or (c==-1):
print(“NO”)
else:
print(“YES”)

This is the link of the code above

I think u did not get the problem statement,
“Due to Chef’s limited vocabulary, he sometimes mixes the languages when forming a sentence — each word of Chef’s sentence contains only characters from one of the languages, but different words may come from different languages.”
because your code is failing on simple test case like
1
3 N N N
your code output is No
expected output in Yes
You need to keep a condition of up , low and c inside k loop

If you want u can go through my solution → CodeChef: Practical coding for everyone

1 Like