ROBOGAME - unable to find the corner case for which my code is failing

Here is my code for the ROBOGAME problem.
I am not able to find the test case (corner case) for which my code is failing.

#include <stdio.h>

char s[60];
int len = 0;
int function();

int main()
{
    int test_case;
    scanf("%d", &test_case);
    for (; test_case > 0; test_case--)
    {
        scanf("%s", s);

        while(s[len] != '\0') {
            len++;
        }

        if(function()) printf("unsafe\n");
        else printf("safe\n");
    }
    return 0;
}

int function()
{
    for (int i = 0; i < len; i++)
    {
        if ((s[i] != '.') && (s[i] != 'x')) {
            int digit = s[i] - '0';
            int lower_limit = i - digit;
            if (lower_limit < 0) lower_limit = 0;
            int upper_limit = i + digit;
            if (upper_limit > len - 1) upper_limit = len - 1;

            for (int j = lower_limit; j <= upper_limit; j++) {
                if (j != i) {
                    if (s[j] == '.') s[j] = 'x';
                    else return 1;
                }
            }
        }
    }
    return 0;
}

Just check that the distance between any two adjacent robots is more than the sum of their range

You don’t reset len, so previous strings can interfere with the current string.

example:

2
....7
2..

On the second testcase, len is still 5 and the 7 from the first case has not been overwritten so your code reports the case is unsafe.

print answer of each test case in a new line :slight_smile:

@vijju123 I did try with that. It’s still being me “wrong answer”

Yeah, I show that approach in successful submits. But I want to know what is wrong with my approach. It is giving correct answer for all the test case I can think of.

ahhh, thank you…that is what I was missing.