6 kyu

Chunky strings

Description
Loading description...
Strings
Recursion
  • Please sign in or sign up to leave a comment.
  • o2001 Avatar

    C# Translation (straightforward 1-1 to my earlier c++ translation).

  • SS-Stefanov1 Avatar

    Fun kata, but the rules of how we should achieve the desired result could be a bit clearer

  • JohanWiltink Avatar
  • o2001 Avatar
    • dfhwze Avatar

      done

      Suggestion marked resolved by dfhwze 6 months ago
    • o2001 Avatar

      Just to note, I accidentally left the It title for the random tests as empty_string rather than random_test_cases. I just used the editor to patch this up. Hope that's fine

    • Blind4Basics Avatar

      Don't use the editor, use rather the fork button, if you see it (just on the left of the edit button). The edit panel has side effects on contributors, when it comes to progress elligibility (as in: losing it), if they want to complete the kata in multiple languages and/or translate it also with the idea of gaining the progress in that language.

    • o2001 Avatar

      Oh that's strange - noted. Sorry if this affected anyone I just assumed this was too minor of a change to warrant forking again

    • Blind4Basics Avatar

      no, the only potentially affected person is you, that's all.

  • St1tched Avatar

    The "make_chunk" method in random tests needs to be modified to accept a maximum depth parameter, which will help prevent occasional recursion limit errors during the generation of test cases.

  • JohanWiltink Avatar

    valid chunky strings of length in the range 1 .. 200

    IMO 0 is a perfectly good number, an empty string is a valid chunky string, and there should be a test with it.

    • JohanWiltink Avatar

      The fact that the example solution pukes on chunky strings of length 0 only strengthens me in this opinion.

    • Paul Robertson Avatar

      Ok, fixed.

      Suggestion marked resolved by Paul Robertson 6 months ago
    • JohanWiltink Avatar

      I just noticed fixed tests only use, and random tests always generate, strings of exactly 1 chunk. The specs leave open the possibility of a string containing any number of chunks.

      What is the intention here?

      If a chunky string is supposed to be exactly one chunk, length 0 actually does not make sense. ( The specs should also just say so. ) If a chunky string can contain multiple chunks, there should of course be tests with that.

    • JohanWiltink Avatar

      With make_chunk(depth), there is no real reason to specify an upper bound to the string length anymore.

    • o2001 Avatar

      The description now states that "A 'chunky string' is a string consisting of exactly one chunk.". So yes, the empty string case should be done away with; the only other alternative is to consider an empty string a valid chunk, which would lead to absurd conclusions

    • Paul Robertson Avatar

      The intention was that a chunky string consists of exactly one chunk. I think I'll keep it like that for this kata.

      I have kept an upper bound on the string length to limit the amount of output in case of an error

    • Paul Robertson Avatar

      Empty string test case is now gone

    • o2001 Avatar

      No need for an upper bound if you set the recursive limit to 8 (in which case the maximum will be 255) or 7 (~115 or something iirc).

  • dfhwze Avatar
  • dfhwze Avatar

    Method "make_chunk" in random tests should be adapted to take a maximum depth to avoid occasional recursion limit errors in test case generation.

  • dfhwze Avatar

    Is it possible random tests could result in recursion limit?

    
    RecursionError: maximum recursion depth exceeded while calling a Python object
    
    Traceback (most recent call last):
      File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper
        func()
      File "/workspace/default/tests.py", line 34, in random_strings
        s = make_chunk()
            ^^^^^^^^^^^^
      File "/workspace/default/tests.py", line 25, in make_chunk
        return '['+ make_chunk() + make_chunk() + ']'