#82Evil Autocorrect Prank


Your friend won't stop texting his girlfriend. It's all he does. All day. Seriously. The texts are so mushy too! The whole situation just makes you feel ill. Being the wonderful friend that you are, you hatch an evil plot. While he's sleeping, you take his phone and change the autocorrect options so that every time he types "you" or "u" it gets changed to "your sister."


Write a function called autocorrect that takes a string and replaces all instances of "you" or "u" (not case sensitive) with "your sister" (always lower case).


Return the resulting string.


Here's the slightly tricky part: These are text messages, so there are different forms of "you" and "u".


For the purposes of this kata, here's what you need to support:


"youuuuu" with any number of u characters tacked onto the end

"u" at the beginning, middle, or end of a string, but NOT part of a word

"you" but NOT as part of another word like youtube or bayou


 #74 CamelCase to underscore


You wrote all your unit test names in camelCase. But some of your colleagues have troubles reading these long test names. So you make a compromise to switch to underscore separation.


To make these changes fast you wrote a class to translate a camelCase name into an underscore separated name.


Implement the ToUnderscore() method.


Example:


"ThisIsAUnitTest" => "This_Is_A_Unit_Test"


But of course there are always special cases...


You also have some calculation tests. Make sure the results don't get splitted by underscores. So only add an underscore in front of the first number.


Also Some people already used underscore names in their tests. You don't want to change them. But if they are not splitted correct you should adjust them.


Some of your colleagues mark their tests with a leading and trailing underscore. Don't remove this.


And of course you should handle empty strings to avoid unnecessary errors. Just return an empty string then.


Example:


"Calculate15Plus5Equals20" => "Calculate_15_Plus_5_Equals_20"


"This_Is_Already_Splitted_Correct" => "This_Is_Already_Splitted_Correct"


"ThisIs_Not_SplittedCorrect" => "This_Is_Not_Splitted_Correct"


"_UnderscoreMarked_Test_Name_" => _Underscore_Marked_Test_Name_"




+ Recent posts