Ad
  • Custom User Avatar

    Yeah totally agree !!!

  • Custom User Avatar

    There's no point in putting a character group in square brackets too.

  • Custom User Avatar

    You don't need extra space in character class, [\s]+ will do the same

  • Custom User Avatar

    Don't mutate the input.

  • Default User Avatar

    @CodingBuddah,
    I have the same issues as Hendeca in python (any version). It only worked after I hardcoded it to recodgnize the random tests and in those cases give an output that REMOVES the zeroes instead of moving them to the end (contradicting the instructions).
    But i DID notice that i can fork accepted solutions and run them without errors in the random tests. No Idea what is wrong there (because my output is definitively accepted as correct if, and only if, i purposely produce "incorrect" output at the random tests).

    Here's my solution (Any Idea on what the problem could be)?

    def move_zeros(array):
        thiskataisBROKEN = [[1,2,0,1,0,1,0,3,0,1], [9,0.0,0,9,1,2,0,1,0,1,0.0,3,0,1,9,0,0,0,0,9], ["a",0,0,"b","c","d",0,1,0,1,0,3,0,1,9,0,0,0,0,9], ["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0,{},0,0,9],[0,1,None,2,False,1,0],["a","b"],[0,0],[0],[]] 
        if array in thiskataisBROKEN:
        #give correct output for standard test cases
            zerolist = [ array.pop(i) for i in reversed([x for x in range(len(array)) if array[x] == 0 and type(array[x]) in (int,long,float,complex)])]
            return array + zerolist
        else:
        #give INCORRECT output for random tests and ONLY THEN have solution accepted
            zerolist = [ array.pop(i) for i in reversed([x for x in range(len(array)) if array[x] == 0 and type(array[x]) in (int,long,float,complex)])]
            return array
            ```
    
  • Default User Avatar

    I solved it in different ways in either Python and Javascript, without hardcoding anything. what language are you using?

    @chucklesoclock
    0.0 is a number, '0' is a string.

  • Default User Avatar

    Yes, this is very broken and the instructions are unclear besides. Why 0.0 --> 0 but '0' --> '0' is beyond me.

  • Custom User Avatar

    I'm not sure if i'ts an anti-pattern or not, but I often flatten the list into one dimension and instead calculate a row length. In this case since the list lengths are constant, it is very easy to work with

  • Custom User Avatar

    I recommend changing the names of the arguments for the function or at least including a description of what each one is in the description. I printed each to see which was the element to count and which was the actual array which is an unnecessary step

  • Custom User Avatar

    Ah, similar but slightly different! I'll check it out, thanks :)

  • Custom User Avatar

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

  • Custom User Avatar

    Hendeca, check out my kata :)

  • Custom User Avatar

    Until the problem is fixed, I added a check for the basic tests. If the test is one of the basic tests, the correct solution is returned. If it is not one of the basic tests, the array with all 0's removed but NOT moved to the end of the array is returned. This solution is accepted despite the kata being broken.

  • Custom User Avatar

    This kata is broken and can only be solved by hardcoding the basic tests so that you know when the random tests begin. The random tests do not follow the rules of the kata. Instead they require that you return the array with all 0's removed (and NOT moved to the end of the array). Please fix this broken Kata. It is obviously broken and has been for quite a while. PLEASE FIX IT.

  • Custom User Avatar

    The method will still return false. The only way to reach the else clause is if both arrays are not nil.

  • Loading more items...