Retired

String chunks (retired)

457 of 1,020keune
Description
Loading description...
Strings
Fundamentals
  • Please sign in or sign up to leave a comment.
  • fikotta Avatar

    Callers error:

    Traceback (most recent call last):
      File "/workspace/default/.venv/lib/python3.10/site-packages/codewars_test/test_framework.py", line 112, in wrapper
        func()
      File "/workspace/default/tests.py", line 19, in basic_test_cases
        test.assert_equals(string_chunk('the girl is missing'), []);
    TypeError: string_chunk() missing 1 required positional argument: 'n'
    
  • saudiGuy Avatar
  • hobovsky Avatar

    This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/202.
    Please join the discussion to help us identify duplicate kata and retire them.

  • Alex Sky Avatar

    This comment has been hidden.

  • adbiLenLa Avatar

    #11b2T/3pz:0z:vV <\br> this really demonstrates the power of the list comprehension

  • Haksell Avatar

    Oh come on, if your program gets "3angle" as an integer input, you should let it die, not pass the error silently to the next unsuspecting function.

  • Pupiniaaa Avatar

    This comment has been hidden.

  • FArekkusu Avatar

    a function that takes a positive integer n

    So why are there tests with n being a string?

  • adrian.eyre Avatar

    Ruby translation, please check and approve :-)

  • kreitzo Avatar

    This comment has been hidden.

  • karazyabko Avatar

    Passed all the tests, recieved:

    FATAL ERROR: JS Allocation failed - process out of memory 5 Passed 0 Failed 0 Errors Process took 2268ms to complete

    Is it a problem on your side or I`m doing something wrong?

  • 01luiyi Avatar

    Hi iam stuck on test case ['bizarre love'] should equal [], on invalid chuck size 7 passed 1 failed. I run the following assertion: test.assert_equals(string_chunk('bizarre love',), []); and pass it. Iam not sure if this is what the test case wants me to do, but with that description i dont see the mistake or whats the result it should be. Any ideas?. THX

  • fs2405 Avatar

    The test cases don't check the case [n > length of the string], but the instructions demand to handle that case:

    "If n is greater than the lenght of the string, you should return an array with the only element being the same string."

    So currently that part could be left out and you still get to submit your final solution.

  • gabericharde Avatar

    Receiving the following Failed pass after 6 valid passes:

    Expected: [], instead got: [""]

    Trying to recreate the same input that would give me [""] in my test runs, but so far nothing. Any ideas?

  • brianpck Avatar

    This comment has been hidden.

  • ecocode Avatar

    Can anyone please advise me why it says my code passed all tests with 0 failed and 0 errors and still gives 'Incorrect' in the end with red colour? Any help will be greatly appreciated. Thanks.

  • ogeidemol Avatar

    This comment has been hidden.

  • naveenkmoorthy Avatar

    I'm getting an error "Expected: ["hel","lo ","wor","ld"], instead got: ["hel","lo","wor","ld"]". Any help will be appreciated :)

  • pre Avatar

    Typo in description: "If n is not a valid size(> 0) (or is absent)" should be <0 (less than 0) rather than greater than 0 as it's describing invalid conditions.

    Also a small typo in the next line 'lenght' --> 'length'

  • belgarathcjd Avatar

    I've written my code and it has passes when I hit test. However when I submit it It passes the tests again (including the invalid chunk size tests) then throws up this error:

    "Traceback: in TypeError: string_chunk() takes exactly 2 arguments (1 given)"

    Cannot figure out what is wrong on my end, is it an error with the test cases? Any help is greatly appreciated

  • CMLL Avatar

    I want to give crap for those edge cases... but I understand that they are day to day stuff we have to deal with, so I wont. Only one thing tough, there is one case that has you modifying the function chunk argument. That should already be taken care of, for the simple reason that the function definition appears by default, and most people don't think of changing any of that, at the assumption that the author created it correctly.

    So, either remove the complete function definition or eliminate the case when no chunk size is entered. It could be left if the feedback from the test cases were more accurate but in my case all I got was that process took way too much time to complete, it never told me anything about missing arguments.

  • halcyonjuly7 Avatar

    kata is easy author said.good luck with random edge cases

  • CMLL Avatar

    This comment has been hidden.

  • CrazyMerlyn Avatar

    Python translation kumited.

  • CrazyMerlyn Avatar

    I'm not sure if that's your intention but the length and chunkSize during random tests are not random. length is always 100 and chunksize always 20.

  • evgeniy_gor Avatar

    This comment has been hidden.

  • bojidar-bg Avatar

    Added a coffeescript translation!

  • bojidar-bg Avatar

    The description is quite bad... Here are some suggestions:

    1. What is a "valid size" ?
    2. Why not just say that the function should split the string into part of n length? The current explantion ('takes a string and a positive integer n, and returns an array of strings of n length') is quite vague.
  • DivyanshBatham Avatar

    This comment has been hidden.

  • DivyanshBatham Avatar

    Hey keune with reference to your 3rd Example - stringChunk('hello world', 3) // ['hel', 'lo ', 'wor', 'ld'] I think your 2nd Example should be stringChunk('this kata easy', 4) // ['this', ' kat', 'a ea', 'sy'] am I right??