Ad
  • Default User Avatar

    Thank you! I'm not sure why [mutating the argument] didn't give a bad test result on all of them.

    I don't know if this is the best solution, but I just added this line as the first line of my function:

    args = args[:]
    

    to make a separate copy of args to manipulate. After that, all my tests succeeded.

  • Default User Avatar

    Classic one... ;)

    Don't mutate the argument, it's bad practice (and it's what generate your troubles ;) )

  • Default User Avatar

    I'm getting an issue with the random tests in Python.

    There was a randome test with this input: [-69, -66, -65, -64, -63, -62, -59, -58, -55, -54, -53, -52]

    and the test failed, giving me this error message:

    It should work for random inputs too: '-69,-66--62,-59,-58,-55--52' should equal ''

    I'm getting a lot of random tests where the unit test believes the output should be an empty string. Am I missing something in the instructions? I'm wondering if it's expecting '' because the input is invalid, but it doesn't look invalid to me.

  • Custom User Avatar

    @juliand665 -- ah! you're correct -- that makes sense.

  • Custom User Avatar

    There should really be more than one test case in the attempt to check for edge cases and prevent overfitting (and it's a kindness to have sample test cases pre-written :) )

  • Custom User Avatar

    Don't know much about ruby, but I'm pretty sure that's how they're converting the numbers to strings.

  • Custom User Avatar

    I don't know what post you're answering to, but what you're saying is false:
    ['this is', 'a good example'].join(' ') => 'this is a good example'
    'this is a good example'.split(' ') => ['this', 'is', 'a', 'good', 'example']
    thus ['this is', 'a good example'].join(' ').split(' ') => ['this', 'is', 'a', 'good', 'example']

  • Custom User Avatar

    Why are you doing join(" ").split(" ")?

    arr.join(" ").split(" ") == arr

  • Custom User Avatar

    I realize that these kata are written for multiple languages, but in Ruby this should really be written as a predicate:

    Array.same_structure_as?(other)

    since it only returns a boolean.

  • Custom User Avatar

    ugh. this is so elegant I hate my solution.

  • Custom User Avatar

    The instructions should be more clear, or the test cases should provide more output.

    The script I wrote fails on the third test, but there is inadequate information in the Instructions to know what additional circumstances I should account for.