Ad
  • Custom User Avatar

    You are missing something, but we cannot tell you what you are missing without seeing your code.

  • Custom User Avatar

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

  • Default User Avatar

    closing, as this would be a suggestion anyways, not an issue. there are ways to properly free all of the memory in a standard-compliant way, and without using global variables.

  • Default User Avatar

    assertion messages for the PHP random tests are completely unhelpful: Failed asserting that false is true

  • Default User Avatar

    your solution is wrong, for example for observed = "00001", it will return an array like array(48) { "88818", "08818", "80818", "00818", ... } --> the 1 is treated as if it was in the 4th position, while it is in the 5th position in the input. though it is true that assertion messages are horrendous in PHP, i will raise an issue about that.

  • Default User Avatar

    the error comes from your code: wrong index calculation, so you access invalid memory

    char *pos = (char*)(pins + (sizeof(char *) * num_pins) + ((cur_idx) * len));
    

    should be:

    char *pos = (char*)pins + sizeof(char *) * num_pins + cur_idx * (len + 1);
    

    (you forgot the + 1 for the nul terminator, and you got the pointer arithmetic wrong: ptr + n will add n * sizeof *ptr to ptr, so you were going out-of-bounds of pins. The cast to char * needs to happen right away, in order to have byte-level memory access.)

  • Custom User Avatar

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

  • Custom User Avatar

    Really sorry, I didn't know that I had tried to attempt this kata a long period back.
    That code was mine actually :/
    My bad!

    Thanks for the reply!

  • Custom User Avatar

    The initial solution in python does not have any function body for __init__, I'm not sure where you're getting that from.

    That said, you should never raise a BaseException. The exact exception type doesn't matter for this kata, but it should be a concrete type, not the base class. Try raise ValueError(...), it will fix your issue.

  • Custom User Avatar

    Hi!
    The author has given the following code in the object constructor in the Python Solution's preloaded code:

    try:
      # parse the string
    except Exception:
      raise BaseException("Error occured while parsing version!")
    

    Now my solution works for all the fixed tests, however Test 7 Exception Calls is just not passing :c
    I'm handling the rollback error as well
    But it's stopping at the error I've just written above in the code.

    What could be the issue?

    P.S. I'm getting this error:

    Traceback (most recent call last):
      File "/workspace/default/solution.py", line 14, in __init__
        self.maj = int(v[0])
                   ^^^^^^^^^
    ValueError: invalid literal for int() with base 10: 'a'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/workspace/default/tests.py", line 4, in <module>
        @test.describe("Sample tests")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      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 50, in sample_tests
        @test.it("Exception calls")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
      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 53, in it_7
        VersionManager("a.b.c")
      File "/workspace/default/solution.py", line 20, in __init__
        raise BaseException("Error occured while parsing version!")
    BaseException: Error occured while parsing version!
    

    I'd appreciate your help!

  • Custom User Avatar

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

  • Custom User Avatar

    It was nice practicing my recursion skills after long C:
    Nice kata!

  • Custom User Avatar

    Nice kata! I'm getting started with recursions and this kata was a good experience practicing that + the concept of generators in Python :)

  • Custom User Avatar

    Gotta say calculating the transmission rate was the toughest part of the problem for me!
    Nice kata!!

  • Custom User Avatar

    Thanks for sparing your time for letting know your thoughts!
    I shall be definitely focusing on all the points you had mentioned from the next turn!
    Thanks again!

  • Loading more items...