+ 1
Security(Hard) - lacks adequate test sample [code coach] here is why!
This code shouldn't pass https://code.sololearn.com/cZLH6rQ4mG4H/?ref=app This code doesn't even check for multiple guards, it passes because the test sample doesn't check for one situation which is: xTxxGxGxx$xxGxx Again the code saves one guard location, in case of multiple guards it just overrides the previous guard location so the code reads: xTxxxxxxx$xxGxx Which doesn't output the expected result, meaning this code fails.
2 Respuestas
0
Interesting find!
Yeah, there are only very few tests, and some important variations may be missing...
You should also email it to them, it's more likely they'll see it (although I doubt anything will happen).
0
Here is my code :
//Created by Gaurav Kaushik
#include <iostream>
#include <cstring>//for strlen(str.c_str())
using namespace std;
int itr = -1;//function retruns this variable
int it(string str , char ch , int start){
::itr = -1;//reset the value of it global variable
int *n = new int;
*n = strlen(str.c_str());
while(start >= 0 && start < *n)
{
if(str[start] == ch)
{
itr = start;
break;
}
start++;
}
delete(n);
return ::itr;
}
int main() {
string input = "xxxGxTxx$xxGx";
input.clear();//clearing input before input
getline(cin, *input);
//continuous input to avoid blanklines
int *n = new int;
*n = strlen(str.c_str());
while( *n <= 0)
{
getline(cin,input);
}
delete(n);
int flag =1,T = 0, S = it(input, '#x27;,0);//there is only one $ so
if(S != -1)
{
while(T >= 0 ){
T = it(input, 'T',T);
if(T==-1)
break;
if(T < S){
for(int i = S; i > T; i--){
if(input[i] == 'G'){
flag = 0;
break;
}
}
}
else if(T > S){
for(int i = S; i < T; i++){
if(input[i] == 'G')
{
flag = 0;
break;
}
}
}
}
}
if(flag == 1){
cout << "ALARM" << endl;
}
else{
cout << "quiet" << endl;
}
return 0;
}