# cook your dish here
t=int(input())
for j in range(t):
a=list(input())
b=list(input())
c=list(input())
for i in range(2):
if a[i]=='l':
if b[i]=='l' and b[i+1]=='l':
print("yes")
break
elif b[i]=='l':
if c[i]=='l' and c[i+1]=='l':
print("yes")
break
else:
print("no")
There are two more cases.
Those cases are:
l x x
l x x
l l x
and
x l x
x l x
x l l
no, the L shape should be formed with only three indexes
Your code prints “no” in the following test case:
1
alb
cld
gll
But the answer is “yes”, since there is an ‘l’ shape formed at the bottom right.
The following code works:
t=int(input())
for j in range(t):
a=list(input())
b=list(input())
c=list(input())
flag = False
for i in range(2):
if a[i]==‘l’:
if b[i]==‘l’ and b[i+1]==‘l’:
flag=True
if b[i]==‘l’:
if c[i]==‘l’ and c[i+1]==‘l’:
flag=True
if flag:
print(“yes”)
else:
print(“no”)