A simple FizzBuzz using strings.
- 1 word or phrase (string)
- 2 unique characters
The word or phrase with each occurrence of the first character replaced with fizz and each of the second character replaced with buzz
- The first letter in both Fizz and Buzz must remain capitalized
- For the rest of the words fizz and buzz, you must match the case of the replaced character (if no case then keep lowercase)
- If given characters are not in the phrase, output the original phrase
Given: Hello, h, l Output: FIZZeBuzzBuzzo Given: test, a, b Output: test Given: PCG rocks!, , ! PCGFizzrocksBuzz Given: This Is SPARTA!, , S Output: ThiBuzzFizzIBuzzFizzBUZZPARTA! Given: FizzBuzz, a, b Output: FizzBUZZuzz
This is code-golf so the shortest code, in bytes, wins!
Technically handling the newline case (This Is SPARTA!) is a part of the challenge. However, I will not void an answer for not including it, as it is very challenging or even impossible in some languages.