Ad
  • Custom User Avatar

    Well, the tests are outrageously bad, so...

  • Custom User Avatar

    Oh my, it's really not a good solution... looks clever, but it isn't (in multiple ways)

  • Custom User Avatar

    You're right. Now I think that this is not a good solution in any case.

  • Custom User Avatar

    This will not work if the string contains an even number of duplicates of a word, or a word that is a reverse of another word in the string. Consider the input stressed desserts.

    In the first iteration of the for loop, all instances of stressed will be replaced with desserts, leaving str equal to desserts desserts.

    In the second iteration, all instances of desserts will be replaced with stressed, including the desserts introduced by the first iteration's replacement.

    This gives the incorrect output stressed stressed.

    If a word is repeated an even number of times, this solution will also reverse the reversal for that word.

  • Custom User Avatar

    Perhaps indentation?

    General advice:

    1. Get the parameters of the failed test. AFAIK every programming language here at CodeWars has some way to print something.
    2. Get your result.
    3. Re-read the kata's description. There are a lot of issues where the user missed something in the description.
    4. Check your result manually (if possible). There are quite a few issues where the user's result was just wrong.
    5. If you ask for help
      • Consider asking on the Gitter channel. You might get an aswer in a much more timely manner.
      • State your programming language and version as shown at the top of the page.
      • State the parameters of the failed test, your result and the expected result (if available).
      • Add your solution code surrounded by lines with three backticks (```) and mark the comment as "having spoiler content".
      • Label the comment as "Question".
  • Custom User Avatar
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution