# GOC2002 "Next Attack" -Editorial

MEDIUM

### PROBLEM:

Due to ongoing escalating tensions between two nuclear powered countries, all the security forces and intelligence wing are on high alert. There are high probablity that there will be a strike in our country. The RAW, through their informers, found a few documents which containts a string of random charachter and numbers. These document are submitted to National Technical Research Organisation (NTRO) for decrypting. There is another input from Tactical team of Indian Army intercepted through radio channel and found enemy saying “Sequence is 53568”. The NTRO officer strongly believes there is strong link between this two inputs and this may help find the strike location. The officer gives a try. He decides to extract all the single and double digit no. from the file and arrange them according to the sequence. Now the number achieved after the sequence is converted to character using ASCII value.

### AUTHOR’S AND TESTER’S SOLUTIONS:

``````

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int main() {
// your code goes here
char str[50];
char seq[10];
int i=0,k;
int dig[10];
char ch;

scanf("%s",str);
scanf("%s",seq);

char *p = str;
while (*p) {
if (isdigit(*p)) {
long val = strtol(p, &p, 10);
dig[i]=val;
//    printf("%d\n", dig[i]);
i++;
} else {
p++;
}
}
i=0;

//  char seq[]="123456";
while (seq[i]!='\0')
{
ch = seq[i];
k= seq[i]-48;
//      printf("k->%d  ",k);
//    printf("%dc\n",dig[i+1]);
printf("%c",dig[k-1]);
i++;
}

return 0;
}

``````
//