Ad
  • Custom User Avatar

    I think its because the question asks for groups of CONSECUTIVE size difference? With a class of one, the only consecutive solution would be [1,0]. While that may be correct in a purely mathematical way, that would not really be dividing the class in any actual groups (which was what was asked for).

  • Custom User Avatar

    I do not quite understand: at which point are you using that "product" import from itertools?

  • Custom User Avatar

    totaly valid solution. Feels a bit like cheating though... X)

  • Custom User Avatar

    Damn, i had the same issue. thanls for clarifying

  • Custom User Avatar

    One test case seems incorrect, given the wording of the instructions:
    the test case t = 163, k = 3, ls = [50] is expected to return "None". But according to the instructions it should be "50"
    since the guy wants to travel LESS than t miles and visit LESS than k cities and the woman is happy to visit as many cities as possible on her list ( which is one in this case) the correct solution would be to travel to her one and only destination (which is 50 miles away: less than t miles and less than k cities. all that the guy wanted)

    or am i wrong? (nice kata anyway, though)

  • Custom User Avatar

    Not really a big problem, but the Kata does not actually specify that shift will not be larger than the length of the alphabet. Most of the accepted solutions would not work if shift was set larger than 26.
    Perhaps either more test cases with larger shift values should be given, or a shift-size <= 26 should be specified in tha kata description?

  • Custom User Avatar

    Nice, but I noticed the kata did not actually specify that shift would never be larger than the Alphabet size. Although not present in the test.cases, this solution will not work if shift > 26.

  • Custom User Avatar

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

  • Custom User Avatar

    This is no issue with "False" != 0

    For the following (random) test:
    [0, 0, -9, 'b', True, 6, 'x', 'pippi', 1, -6, -10, 0, -7, 'pippi', 6, -6, 5, 0, -7, 0, 0, 7, 'b', 'y', 4, -5, 0, 'z']
    ,the only accepted (even though clearly incorrect) solution is:
    [-9, 'b', True, 6, 'x', 'pippi', 1, -6, -10, -7, 'pippi', 6, -6, 5, -7, 7, 'b', 'y', 4, -5, 'z']

    Which is simply WRONG as it contradicts the Instructions

    The correct solution SHOULD be:
    [-9, 'b', True, 6, 'x', 'pippi', 1, -6, -10, -7, 'pippi', 6, -6, 5, -7, 7, 'b', 'y', 4, -5, 'z', 0, 0, 0, 0, 0, 0, 0], but this is marked as "incorrect" during the random tests.

    At least in python, this test can only be passed by hardcoding it to give the INCORRECT answer at random tests. Maybe you have been using something different than python, and only the python version is broken?

  • Custom 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
            ```
    
  • Custom User Avatar

    The expected solution of the random tests contradict the Instructions.

    For example with the following input-array:
    [0, 0, -9, 'b', True, 6, 'x', 'pippi', 1, -6, -10, 0, -7, 'pippi', 6, -6, 5, 0, -7, 0, 0, 7, 'b', 'y', 4, -5, 0, 'z']

    my solution (wich is marked as incorrect) gives:
    [-9, 'b', True, 6, 'x', 'pippi', 1, -6, -10, -7, 'pippi', 6, -6, 5, -7, 7, 'b', 'y', 4, -5, 'z', 0, 0, 0, 0, 0, 0, 0].

    But the stated expected solution is given as:
    [-9, 'b', True, 6, 'x', 'pippi', 1, -6, -10, -7, 'pippi', 6, -6, 5, -7, 7, 'b', 'y', 4, -5, 'z']

    So the expected solution simply REMOVES all zeros, while the instructions clearly state that the zeros should be MOVED TO THE END of the array

  • Custom User Avatar

    How come this doesn't raise an IndexError ("list index out of bounds") in Python, as soon as i reaches len(arr)?

    I did not know you could slice arrays with indices larger than the array length...

  • Custom User Avatar

    Thanks for the explanation. I am slowly getting the rough Idea, but I still don't believe I would have ever come to this solution. Great Idea. I'm envious.

  • Custom User Avatar

    It works. You just copied it incorrectly. No need to whine about it

  • Custom User Avatar

    I think this kata could be made more challenging, but also more on topic, by asking for the reverse complement DNA sequence.

    (The exact complement is rarely needed anyway due to the standard convention of writing all DNA sequences fom 5'-3'.
    So the "complement" should always be written down as the "reverse complement")

  • Loading more items...