Skip to content

Instantly share code, notes, and snippets.

@Jack-Saleem
Created July 17, 2016 13:46
Show Gist options
  • Save Jack-Saleem/2dec19580a646acb93f7bf5b465c7fe7 to your computer and use it in GitHub Desktop.
Save Jack-Saleem/2dec19580a646acb93f7bf5b465c7fe7 to your computer and use it in GitHub Desktop.
codeforces 287A IQTest program in java
import java.util.Scanner;
public class IQTest
{
public static void main(String[] args)
{
Scanner z=new Scanner(System.in);
String[] s=new String[4];
char[][] a=new char[4][4];
for(int i=0;i<4;i++)
s[i]=z.nextLine();
for(int i=0;i<4;i++){
for(int j=0;j<4;j++)
a[i][j]=s[i].charAt(j);
}
int k=0;
boolean flag=false;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
k=0;
if(a[i][j]!=a[i][j+1])
k++;
if(a[i][j]!=a[i+1][j])
k++;
if(a[i][j]!=a[i+1][j+1])
k++;
if(k<=1 || k==3){
flag=true;
break;
}
}
}
if(flag)
System.out.println("YES");
else
System.out.println("NO");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment