ERROR - Editorial

Guys can anyone tell what is wrong with this python code for the problem, according to me it is correct.....

lst=[]
a=int(input())
i=0
while i<a:
    str1=input()
    lst.append(str1)
    i=i+1

i=0

for j in lst:
    if '010' in j and '101' in j:
        print("Good")
    else:
        print("Bad")

Guys can anyone tell what is wrong with this python code for the problem, according to me it is correct…

lst=[]
a=int(input())
i=0
while i<a:
    str1=input()
    lst.append(str1)
    i=i+1

i=0

for j in lst:
    if '010' in j and '101' in j:
        print("Good")
    else:
        print("Bad")

#include
#include
using namespace std;
int main(){
int a;
cin>>a;
while(a–){
string s;int c=0;
cin>>s;
for(int i=0;i<(s.length()-1)&&c<2;i++){
if(s[i]!=s[i+1])c++;
else c=0;
}
if(c==2)cout<<“Good”<<endl;
else cout<<“Bad”<<endl;
}
return 0;
}

link text

@s_pandey01
It is in the checking stage. if ‘010’ in j and ‘101’ in j:
it should use ‘or’ instead of ‘and’. If ‘and’ is used, then ‘Good’ will only print out when both ‘010’ and ‘101’ are in the line.

1 Like

import java.util.Scanner;
class untitled
{
public static void main(String[] args)
{
Scanner kb=new Scanner(System.in);
int test=kb.nextInt();
while(test–>0)
{
String s1=kb.next();
String s2=“010”;
String s3=“101”;
if(s1.contains(s2)||s1.contains(s3))
System.out.println(“Good”);
else
System.out.println(“Bad”);
}
}
}
benefit of java!..
:stuck_out_tongue: