文字列と文字列のリストを指定して、入力文字列のすべての空白を対応する文字列で埋めます。
入出力
入力文字列には、アルファベット文字、スペース、およびアンダースコアのみが含まれます。空ではなく、アンダースコアで始まりません。つまり、入力文字列は正規表現と一致します^[a-z A-Z]([a-z A-Z_]*[a-z A-Z])?$
入力リストのすべての文字列は空ではなく、英数字とスペースのみが含まれています。つまり、正規表現に一致し^[a-z A-Z]+$
ます。
ブランクとは、アンダースコアが前後に連続しない連続したアンダースコア(_
)シーケンスです。
入力文字列にはn
正の整数の空白がn
含まれ、文字列のリストには文字列が正確に含まれn
ます。
出力はk
、入力文字列の各-th空白をk
文字列の入力リストの-th文字列で置き換えることにより取得されます。
例
入力文字列"I like _____ because _______ _____ing"
と文字列のリストを指定すると、["ice cream", "it is", "satisfy"]
次のように出力を見つけることができます。
- 最初の空白はの直後にあり
"like "
ます。を"ice cream"
取得するにはを入力します"I like ice cream because ______ _____ing"
。 - 2番目の空白はの直後にあり
"because "
ます。を"it is"
取得するにはを入力します"I like ice cream because it is _____ing"
。 - 3番目の空白はの直後にあり
"is "
ます。を"satisfy"
取得するにはを入力します"I like ice cream because it is satisfying"
。
最終的な文字列を出力します"I like ice cream because it is satisfying"
。
テストケース
input string, input list => output
"Things _____ for those who ____ of how things work out _ Wooden",["work out best","make the best","John"] => "Things work out best for those who make the best of how things work out John Wooden"
"I like _____ because _______ _____ing",["ice cream","it is","satisfy"] => "I like ice cream because it is satisfying"
"If you are ___ willing to risk _____ you will ha_o settle for the ordi_____Jim ______n",["not","the usual","ve t","nary ","Roh"] => "If you are not willing to risk the usual you will have to settle for the ordinary Jim Rohn"
"S____ is walking from ____ to ____ with n_oss of ___ W_____ Churchill",["uccess","failure","failure","o l","enthusiasm","inston"] => "Success is walking from failure to failure with no loss of enthusiasm Winston Churchill"
"If_everyone_is_thinking ____ ____ somebody_isnt_thinking G____e P____n",[" "," "," ","alike","then"," "," ","eorg","atto"] => "If everyone is thinking alike then somebody isnt thinking George Patton"
"Pe_________e __say ____motivation does__ last Well___her doe_ bathing____thats why we rec____nd it daily _ __________lar",["opl","often ","that ","nt"," neit","s"," ","omme","Zig","Zig"] => "People often say that motivation doesnt last Well neither does bathing thats why we recommend it daily Zig Ziglar"