#C4036. 4-Digit Code Generator
4-Digit Code Generator
4-Digit Code Generator
You are given a pattern string of length 4. Each character in the pattern is either a digit (0-9) or an asterisk ('*'). An asterisk can represent any digit from 0 to 9. Your task is to generate all possible 4-digit codes that match the given pattern. The output should list the codes in lexicographical (i.e. increasing) order.
For example, if the input pattern is 12*4
, then the output codes should replace the asterisk with every possible digit from 0 to 9, resulting in:
Please note that the input is provided via stdin and the output must be written to stdout. Ensure that your solution handles the pattern correctly and efficiently.
inputFormat
The input consists of a single line containing a 4-character pattern. Each character is either a digit ('0'-'9') or an asterisk ('*').
outputFormat
Output all possible 4-digit codes that match the pattern, each printed on a new line. The output should be sorted in lexicographical order. There should be no extra spaces or blank lines.
## sample12*4
1204
1214
1224
1234
1244
1254
1264
1274
1284
1294
</p>