TCS
Company
Programming
Data Decryption
Data is encrypted in order to maintain security. Encrypted data format and corresponding decryption procedure is described below.
A Data Record consists of exactly two lines. Each Record has exactly two 'F' characters. The first 'F' character acts as field delimiter. The second 'F' character marks the end of the Record. First 'F' characters can be present in either of the two lines. However, the second 'F' is always present only in the first line. Also, since the second 'F' character marks end of the record, it is always the last character of the first line.
The decryption procedure is explained using an example Record
13F6803F
2457959
Note the following things
The Record is comprised of two lines
The Record has 2 'F' characters
The second 'F' character appears as the last character in first line
The length of the first line is one character more than the length of the second line
Other than 'F's, the lines can contain only numeric characters
Data has to be read in following order from left to right
Read first character of first line
Then, read first character of second line
Then, read second character of first line
Then read second character of second line
So on and so forth in zig-zag manner until the first 'F' character is encountered
Replace the first 'F' by | (pipe) symbol
So the first field which is now decrypted is 1234, based on the example above
Continue reading rest of the record by following steps 1 - 4
When second 'F' character is encountered, the record is said to be completely read and we have obtained our second field value as 567890539
Your task is to decrypt set of records. The Input and Output sections below specify how the input has to be read and how the output has to be written.
Input Format:
File Name, where file contains records (recollect that each Record is comprised of 2 lines)
Output Format:
Print the decrypted data delimited by pipe symbol ('|')
Constraints:
There can be maximum 100 records in the input file
The Record length including characters in both lines may not exceed 25
Read Solution (Total 0)
TCS Other Question