Ad
  • Custom User Avatar

    Definitely clever, not sure why people tend to vote best practices on solutions that are nearing code golf level of cleverness though. If most people were straight up handed this code at their job, it'd take them a while to even figure out what it does, let alone work with it.

  • Custom User Avatar

    That was an excellent Kata.

    Piece of advice for everybody working on it: Read the description and think about what you know about the problem.

    Don't be like me, going down a rabbit hole of memoization, optimal factorization algorithms, and obscure code features, only to finally sit down and read the description carefully.

    This problem doesn't require any of that.

  • Default User Avatar

    I will make note for Ruby ;)

  • Custom User Avatar

    Perhaps just constructing a new string would be better?

    Earlier katas stated whether your function was expected to be pure, or whether the author actually copied the arguments beforehand. So @Hybr1d, you probably want to add this to the description. although this only effects Ruby (AFAIK).

  • Default User Avatar

    That immediately solved it, thanks bkaes. I totally forgot about the hoops you have to go through to "copy" an object in Ruby.

    Changing it to dna.dup fixed it.

    Perhaps just constructing a new string would be better?

  • Custom User Avatar

    t isn't a copy, but actually references the very same object as dna. See http://patshaughnessy.net/2012/1/18/seeing-double-how-ruby-shares-string-values for another example.

  • Default User Avatar

    Try not to manipulate given String because test ares testing the opposite then. Since you manipulted it :). Create new String and return that.

    PS: If you still have trouble look online if not enoguh then just pass solution and you will see what you did wrong ;)

  • Default User Avatar

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

  • Default User Avatar

    Oh... don't change the actual input create new string and add to it :). Then it works... like bkeas told you

  • Default User Avatar

    Has the same problem whether I manipulate the input or not, going to post a screenshot.

  • Custom User Avatar

    Does your solution manipulate the argument? Your function needs to be pure, e.g. it may have no side-effects on the argument or the environment. As far as I can see, you change dna inplace, therefore invalidating the argument used for the verification.

  • Default User Avatar

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

  • Default User Avatar

    To be honest I have no idea why...But test work for me just fine post solutin here I will mark it as a spoiler...

  • Default User Avatar

    Input: GGGTTTTCTTTCACC
    Expected: "GGGTTTTCTTTCACC", instead got: "CCCAAAAGAAAGTGG"

    The random tests are expecting the output to be the same as the input.

  • Default User Avatar

    Tell me what is wrong, the test seems fine for me?

  • Loading more items...