Stolen from @Downgoat with permission
The point of this challenge is to (not) settle the debate on the pronunciation of "gif".
The pronunciation of gif is debated and while it's supposed to be (and should be) pronounced jif, it's still commonly disputed.
In this challenge you will be given a set of words that have a g or j, representing the sound that the word is pronounced with. You'll also get some text in which you have to fix the incorrect spellings of gif.
Because this is the internet and everyone always wrong. It's (not) common courtesy to correct them.
An example of a wrong pronunciation would be:
There was a gif of a mouse eating a burrito
The wrong spelling of gif? Unacceptable! This must be corrected immediately:
There was a jif (as in jar) of a mouse eating a burrito
Are we done? Nope, you're still wrong.
You're always wrong
This must work the other way:
In the jif the cat wore a hat of a cat
This obvious misspelling must be fixed, we shall correct this to:
In the gif (as in graphic) the cat wore a hat of a cat
- Input is a string (the sentence) and an array of strings (or any reasonable alternative, such as a comma separated string) in any order
- You may take the
jwords in any order. They may be taken separately.
- Every instance of
gif(any case) in the sentence must be replaced with
jif (as in ___)where
___is a uniformly random selected word beginning with
jfrom the array of strings, and vice versa for
jifwith words beginning with
- ONLY the words
jifshould be replaced (i.e "jiffy" should not be changed). Those words have done no wrong.
- You are guaranteed that at least one word in the array begins with
gand at least one begins with
- Case must be preserved (e.g.
- You may write a program or a function
- Standard loopholes apply
- We need to (not) settle the debate quickly; shortest code in bytes wins
Input and output separated by a single line:
graphic, jar, jam, gram I saw a jif of how to pronounce gif that showed gif is pronounced jif I saw a gif (as in graphic) of how to pronounce jif (as in jar) that showed jif (as in jam) is pronounced gif (as in gram) gravy, jeff G is for gIf, h is for JiF, i is for gIF, j is for JIf G is for jIf (as in jeff), h is for GiF (as in gravy), i is for jIF (as in jeff), j is for JIf (as in gravy) joke, june, gorilla, great Jiffy should not be treated as a GIF or JIF, like gifted. Jiffy should not be treated as a JIF (as in june) or GIF (as in great), like gifted.
The pronunciation of gif is debated and while it's supposed to be (and should be) pronounced **gif,** it's still commonly disputed.FTFY ;) \$\endgroup\$