Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
All submissions for this problem are available.Recently the company Life Ltd created a new logo for themselves. You are asked to test the design of the logo.

The logo is a 3 * 3 square grid with 9 cells. Each cell contains some lower case english letter. This logo will be considered good if there exist three cells in the shape of an L that contain the letter 'l' (lower case 'L') in each of them. That is, there should be a cell with 'l', its cell directly beneath it should also have 'l' and the cell to the right of the second cell should also have 'l'.

Your task is to tell whether the logo is good or not.

Input
The first line of the input contains an integer T denoting the number of test cases. The description of the test cases follows.
Each of the next three lines contains a description of the logo, i-th of the line contains three characters which denote the i-th row of the logo

Output
For each test case, output yes or no according to the answer to the problem.

Constraints
1≤T≤100
Example Input
3
laz
lla
aaa
ala
lla
aaa
lll
lll
lll
Example Output
yes
no
yes

What I have tried:

#include<stdio.h>
int main()
{
char logo[3][3];
int row,col,t,i;
scanf("%d\n",&t);
for(i=0;i<t;i++)
{

for(row=0;row<3;row++)
{
for(col=0;col<3;col++)
{
scanf("%c\n",&logo[row][col]);

}
}
if(logo[0][0]=='l'&&logo[1][0]=='l'&&logo[1][1]=='l')
printf("yes\n");
else if(logo[0][1]=='l'&&logo[1][1]=='l'&&logo[1][2]=='l')
printf("yes\n");
else if(logo[1][0]=='l'&&logo[2][0]=='l'&&logo[2][1]=='l')
printf("yes\n");
else if(logo[1][1]=='l'&&logo[2][1]=='l'&&logo[2][2]=='l')
printf("yes\n");
else
printf("no\n");
}
}
Posted
Updated 21-Dec-18 1:05am
Comments
Patrice T 21-Dec-18 5:17am    
describe the problem.

There is no mistake in your code. You might rewrite it as follows, if you like.

C
#include<stdio.h>
#define N 3

int is_good(char l[N][N]);

int main()
{
  char logo[N][N];
  int row,col,t,i;
  scanf("%d\n",&t);
  for(i=0;i<t;i++)
  {

    for(row=0;row<3;row++)
    {
      for(col=0;col<3;col++)
      {
        scanf("%c\n",&logo[row][col]);

      }
    }
    if ( is_good(logo) )
      printf("yes\n");
    else
      printf("no\n");
  }
}

int is_good(char l[N][N])
{
  int r,c;
  for (r=0; r<N-1; ++r)
    for (c=0; c<N-1; ++c)
      if ( l[r][c]=='l' && l[r+1][c]=='l' && l[r+1][c+1]=='l')
        return 1;
  return 0;
}
 
Share this answer
 
v2
Firstly you have tagged this question C# when it is clearly C.
As to your problem, you are correctly identifying the L shape in sets 1 and 3.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900