#C10256. Wildcard Replacement
Wildcard Replacement
Wildcard Replacement
Given a string s
that contains exactly one wildcard character *
, replace the wildcard with each digit from 0 to 9, and output all resulting strings in lexicographical order. If the input does not contain exactly one *
(i.e. if it contains none or more than one), output an error message.
The lexicographical order here is determined by the natural ordering of the strings (i.e. as if they were compared using string comparison).
You can express mathematically the requirement as follows: Let \( s \) be a string such that \( \text{count}(s, '*') = 1 \). Then for each digit \( d \in \{0,1,2,3,4,5,6,7,8,9\} \), produce the string \( s' \) where the only occurrence of \( * \) is replaced with \( d \). Output all such \( s' \) in lexicographical order. If \( \text{count}(s, '*') \neq 1 \), print Error: Invalid input
.
inputFormat
The input is given via standard input (stdin) and consists of a single line containing the string s
. The string can include digits and exactly one wildcard character *
. If the string does not contain exactly one *
, it should be considered invalid.
Input Format:
s
outputFormat
If the input is valid (i.e. contains exactly one *
), output 10 lines where each line is the string s
with the wildcard *
replaced by one of the digits from 0 to 9, in lexicographical order.
If the input is invalid, output the following error message:
Error: Invalid input## sample
1*3
103
113
123
133
143
153
163
173
183
193