#C4072. Decode Encoded Instructions
Decode Encoded Instructions
Decode Encoded Instructions
You are given a list of encoded instructions. Each instruction is a string containing letters and digits. The decoding process is simple: for every digit in the string, you must output the digit twice; non-digit characters remain unchanged.
For example, the instruction a2b4
is decoded to a22b44
. Use this rule to decode a list of instructions.
Mathematical Formulation: If an instruction is given as \(s = s_1s_2\ldots s_m\), then the decoded instruction \(d\) is defined as:
\( d = \prod_{i=1}^{m} f(s_i) \) where \( f(s_i) = \begin{cases} s_i s_i & \text{if } s_i \text{ is a digit}\\ s_i & \text{if } s_i \text{ is not a digit} \end{cases} \).
inputFormat
The input is read from standard input (stdin). The first line contains an integer (n), representing the number of encoded instructions. Each of the following (n) lines contains a string that represents an encoded instruction.
outputFormat
For each encoded instruction, output the decoded string on a separate line to standard output (stdout). The decoded string is derived by doubling each digit in the original string.## sample
3
a2b4
z1x2c3
g9h
a22b44
z11x22c33
g99h
</p>