wes d2a2ba9e15 first commit | 4 年之前 | |
---|---|---|
.. | ||
README.md | 4 年之前 | |
code.cpp | 4 年之前 | |
unitTest.cpp | 4 年之前 |
by Alex Golubov tags: regex, strings
Wurst is the best. Create a function that takes a string and replaces every mention of any type of sausage with the German word "Wurst," unless—of course—the sausage is already a type of German "Wurst" (i.e. "Bratwurst", see below), then leave the sausage name unchanged. German Wursts | Convert to Wurst --- | --- Bratwurst | Kielbasa Kochwurst | Chorizo Leb
Wurst is the best. Create a function that takes a string and replaces every mention of any type of sausage with the German word "Wurst," unless—of course—the sausage is already a type of German "Wurst" (i.e. "Bratwurst", see below), then leave the sausage name unchanged.
German Wursts | Convert to Wurst |
---|---|
Bratwurst | Kielbasa |
Kochwurst | Chorizo |
Leberwurst | Moronga |
Mettwurst | Salami |
Rostbratwurst | Sausage |
~ | Andouille |
~ | Naem |
~ | Merguez |
~ | Gurka |
~ | Snorkers |
~ | Pepperoni |
wurstIsBetter("I like chorizos, but not sausages") ➞ "I like Wursts, but not Wursts"
wurstIsBetter("sich die Wurst vom Brot nehmen lassen") ➞ "sich die Wurst vom Brot nehmen lassen"
wurstIsBetter("Bratwurst and Rostbratwurst are sausages") ➞ "Bratwurst and Rostbratwurst are Wursts"
All German sausage names contain the word "Wurst".