A simple FizzBuzz using strings.
Given
- 1 word or phrase (string)
- 2 unique characters
Output
The word or phrase with each occurrence of the first character replaced with fizz and each of the second character replaced with buzz
Rules
- 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
Test Cases
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!
Note
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.
you must match the case of the replaced character
andInput is not case sensitive
seem to contradict each other. \$\endgroup\$ThiBuzzFizzIBuzzFizzBUZZPARTA
is missing a final exclamation mark. \$\endgroup\$aa, a, f
? What would be the expected output?BUZZizzBUZZizz
,FizzFizz
, or both allowed at our option? \$\endgroup\$FizzFizz
. \$\endgroup\$