You will be given an input string, anywhere the word
"Lemon" is found it should be converted to
"Lemonade" but the
e must be borrowed from somewhere else in the sentence.
I found a lemon when I was a kid
I foun a lemonade whn I was kid
The Lemonade was created by stealing the following superscript letters from the original
da lemonade wh en I was akid
This is just one possible output example, the "e", "d", and "a", could have been taken from anywhere (except for from the word
lemon of course)
•If there are not enough
ds you must output what was do-able with the letters given. For example the input
bdblemon would output
lemon text might not always be standalone (space on each side). For example you may have the word
lemons somewhere in the input and the output should be
•The input may contain any number of
lemons, even 0
lemons (in which case the output would be identical to the input)
•You can make your lemonade with uppercase and lowercase letters, for example
leMon could become
leMonade, and the
ade borrowed can be any case (so it could also have become
The case of the letter you borrowed must remain what it was when you borrowed it.
(Example input -> output,
he hAD lemOn ->
h h lemOnADe)
•Does not have to be a full program, a function alone is fine.
•You may assume input will be only the CP437 Character Set
This is code-golf, so the lowest number of bytes wins!
*Note: For any given input there might be multiple possible outputs so your program may not output exactly as these test cases do, this is more just so people can understand the logic:
Input: EpaD leMons
Output: p LeMonaDEs
Input: hello world
Output: hello world
Input: lemon lemon
Output: lemon lemon
dletters should never be taken from another "Lemon")
Input: HE HAD lemonade
Output: H H lemonADEade
Input: Do you like lemons? You hAd me at lemon!
Output: o you lik lemonADes? You h m t lemonade!
Input: AE lemon
Input: 55bad lemon
Output: 55b lemonad