Ad
  • Custom User Avatar
  • Default User Avatar

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

  • Default User Avatar

    I want to know how I can identify the best-practice solution, as you mentioned. How can I determine that sorting is not a suitable approach in this situation?

  • Custom User Avatar

    This is actually not the best way of solving this problem. The instructions say to consider there being a large number of inputs. In terms of Big O, if you submitted this solution for production code, you'd have a LOT of people mad at you.

  • Default User Avatar

    that would have been me if mine actually worked.

  • Custom User Avatar

    Im convinced that someone, somewhere, will always know how to write my 50 lines of code in 1 line lol. Very clever. Well done!

  • Custom User Avatar

    I solved it.

    The example above was not the result I intended to show, I hadnt corrected the bug in the kata, only my IDE, thats why there is an ay and repeated '!' marks.
    This is what I intended to show: expected 'Oay emporatay oay oresmay!' to equal 'Oay emporatay oay oresmay !'

    My comment above, in reference to 'not making any sense' was explaining that it makes no sense to have a space in between a word and the punctuation. My result left the punctuation in the correct place (grammatically) after each word that had punctuation (including my own test cases using commas, periods, etc) which is why it failed. I assumed that maybe the example was a typo, clearly I was wrong. This kata was as garbage as my code for it is. Im out.

  • Custom User Avatar

    Yes, the space is on purpose, and no, the reason your code fails it's because it returns a wrong result.

    Leave punctuation marks untouched.

    Why are you adding ay and repeating the ! there?

  • Custom User Avatar

    expected 'Oay emporatay oay oresmay !!ay! ' to equal 'Oay emporatay oay oresmay !'

    I dont understand if the space between the word and exclamation mark is intentional or not but it makes no damn sense and is the reason my code wont pass. Can someone clarify? I see some other comments here concerning the same thing but it seems that not all the test cases follow this rule as I failed one or two assertions with the assumption that punctuation doesnt follow immediately after a word. i fixed it to assume punction WILL immediately follow, i fail a different test case. Again... Why?

    hisTay hitsay siay admay tupidsay, ightray?

  • Custom User Avatar

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

  • Custom User Avatar

    This helped me as well. Thank you for the explanation. I ended scrapping the the use of splice() simply becuase i couldnt figure that out. ended up just deleting the element in the list using delete and using filter to filter out falsy values that were not === 0 till i got what was needed. This was helpful to understand though. Thanks again

  • Custom User Avatar

    Man, I am kicking myself for not implementing the map function lol. I created a new array, a for loop, and a ternary operator to solve the problem, but magaed to do all that in one line. This is really good. Thanks for showing me a more efficent method.

  • Custom User Avatar

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

  • Custom User Avatar

    I like this approach. Well Done. Much cleaner than mine and its still very readable.

  • Custom User Avatar

    People in here are talking mad shit because they cant get away from assuming that everyone on this website is at their level. For some of us, like myself, ive been teaching myself for > 6 months, we dont know how to do everything in one line, and we dont always know when to use one solution vice another. Please chill out.

  • Loading more items...