Ad
  • Custom User Avatar

    It's a method to ignore specific values.

    For instance:

    a,_,b = (1,2,3)
    Then: a=1 and b=3
    Another example:

    a,*_, b = (1,2,3,4,5,6,7,8)
    a = 1 and b = 8

    Other function to this is save the last result in "_" variable.

    So if you do this:

    2+4 -> result= 6

    _ -> result= 6 #save the last result in your program.

    For separate numbers:

    a=100000 #it's confuse to see how many zeros are there.

    But you can do:

    a= 10_000 #it's the same, but more understandable.

    This link helps so much: https://www.datacamp.com/tutorial/role-underscore-python

  • Custom User Avatar

    If you slice sequences by specifying out of bound index, it will slice the sequence to nearest index

  • 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 think I was playing around with diffetent solutions and accidently forget to remove the import.

  • 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

    Added a note.

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

    It seems that in the Python of this, the same object is passed as a variable to the function, and is also used to test the result. I haven't encountered this in other exercises before.

    I just resolved this issue in my own solution, but it seems several people are frustrated by this problem. This seems to be causing unnecessary hassle for people - maybe it's worth changing?

  • Custom User Avatar

    I agree, this issue is not resolved - I am having the same issue.

    Input array:
    [7, 0, 'z', 'c', 0, 7, 0, 'z', 'c', 0, 8, 0, 'y', -6, 'b', 0, 0, False, 2, 9, 8, -4, 0, 0, -2, False, -7, -9, -2, 0, -6, 'pippi', 0, 'z']

    My function's output:
    [7, 'z', 'c', 7, 'z', 'c', 8, 'y', -6, 'b', False, 2, 9, 8, -4, -2, False, -7, -9, -2, -6, 'pippi', 'z', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

    The test's expected output:
    [7, 'z', 'c', 7, 'z', 'c', 8, 'y', -6, 'b', False, 2, 9, 8, -4, -2, False, -7, -9, -2, -6, 'pippi', 'z']

    There are no zeros in the expected output - this appears to be a mistake.

  • Custom User Avatar

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

  • Loading more items...