Ad
  • 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

    Hendeca, check out my kata :)