Ad
  • Custom User Avatar

    Ah--that was a typo. I sorted the coder's results within the test, but forgot to add it to that one specific test. Thanks.

  • Default User Avatar

    I see it. That's a test that's specific to the JS version. It's not even applicable to some of the other languages. It would be simple to "correct", but it's not my code. It's the original author's, so I'll leave that call to him.

    BTW, it's possible to solve this in JS w/out an explicit sort. ;-)

  • Default User Avatar

    javascript - check my solution without the sort to get the error on the fourth test.

  • Default User Avatar

    Which language? I haven't looked at all of them, but at least some don't enforce a ordering of the return values.

  • Default User Avatar

    I had to sort my returning array because the test was not happy with [2, 1] instead of [1, 2]

  • Custom User Avatar

    No, it needs sample tests.

  • Custom User Avatar

    Is there a sample test case? My code failed the sample test case with unknown error but passed the actual tests. Really strange behaviour.

    import re
    def strip_url_params(url, params_to_strip = []):
        split = url.split('?')
        if len(split) == 1:
            return url
        param_string = split[1]
        parameters = [x.split('=') for x in param_string.split('&')]
        test = set(params_to_strip)
        trim_url = lambda param, val: re.sub(r'&%s=%s' % (param, val), '', url)
        for x in parameters:
            if x[0] in test:
                url = trim_url(x[0], x[1])
            test.add(x[0])
        return url
    
  • Default User Avatar

    I had a brainfart while doing this excercise and instead of doing division I did a while loop over k checking each one if it matches. It would be good if one of the test k's would be so big that such approach would not get pass a test :)