algorithms/strings/separate-the-numbers.c
void separateNumbers(char* s) {
    
    long current = 0;
    int size = strlen(s);
    
    for (int i = 0; s[i]; i++) {
        
        current = current * 10 + s[i] - '0';
        fprintf(stderr, "%ld ", current);
        
        bool candidate = false;
        bool valid = true;
        
        int pos = i + 1;
        
        for (int j = 1; pos < size; j++) {
            char next_str[32];
            sprintf(next_str, "%ld", current + j);
            fprintf(stderr, "%s...=%s ", next_str, s + pos);
            int len = strlen(next_str);
            if (strncmp(next_str, s + pos, len) == 0) {
                candidate = true;
            } else {
                valid = false;
            }
            pos += len;
        }
        
        fprintf(stderr, "\n");
        
        if (candidate && valid) {
            printf("YES %ld\n", current);  
            return;      
        }
    }
    printf("NO\n");
}
/*
 * Complete the 'separateNumbers' function below.
 *
 * The function accepts STRING s as parameter.
 */
Complete the 'separateNumbers' function below.
The function accepts STRING s as parameter.
Complete the ' separateNumbers ' function below . The function accepts STRING s as parameter .
void separateNumbers(char* s) {
    long current = 0;
    int size = strlen(s);
    for (int i = 0; s[i]; i++) {
        current = current * 10 + s[i] - '0';
        fprintf(stderr, "%ld ", current);
        bool candidate = false;
        bool valid = true;
        int pos = i + 1;
        for (int j = 1; pos < size; j++) {
            char next_str[32];
            sprintf(next_str, "%ld", current + j);
            fprintf(stderr, "%s...=%s ", next_str, s + pos);
            int len = strlen(next_str);
            if (strncmp(next_str, s + pos, len) == 0) {
                candidate = true;
            } else {
                valid = false;
            }
            pos += len;
        }
        fprintf(stderr, "\n");
        if (candidate && valid) {
            printf("YES %ld\n", current);  
            return;      
        }
    }
    printf("NO\n");
}
void separateNumbers ( char * s ) { long current = 0 ; int size = strlen ( s ) ; for ( int i = 0 ; s [ i ] ; i ++ ) { current = current * 10 + s [ i ] - ' ' ; fprintf ( stderr , " " , current ) ; bool candidate = false ; bool valid = true ; int pos = i + 1 ; for ( int j = 1 ; pos < size ; j ++ ) { char next_str [ 32 ] ; sprintf ( next_str , " " , current + j ) ; fprintf ( stderr , " " , next_str , s + pos ) ; int len = strlen ( next_str ) ; if ( strncmp ( next_str , s + pos , len ) == 0 ) { candidate = true ; } else { valid = false ; } pos += len ; } fprintf ( stderr , " \n " ) ; if ( candidate && valid ) { printf ( " \n " , current ) ; return ; } } printf ( " \n " ) ; }
Complete the 'separateNumbers' function below.
Complete the ' separateNumbers ' function below .