Ad
  • Custom User Avatar

    thanks for the thorough answer!

  • Custom User Avatar
    • char* res=calloc(strlen(s),1);
      
      this does not account for the nul terminator (1 byte is missing)
    • char* res=(char*)malloc(strlen(od));
      
      same remark
    • if(*s=='\0'){
        return "";
      

    the tests expect the returned string to be free()-able. "" is a string literal that cannot be freed

    • if(*od=='\0'){
        char* cp=NULL;
        strcpy(cp,s);
      
    you are attempting to write at the null pointer here. this will crash. you have to allocate memory for `cp`.
    
    
    
    your code passes once all these are fixed.
    
  • Custom User Avatar

    I'd try to reproduce it locally, at the very least you should be able to find out what inputs it happens for by printing (and flushing to ensure it isn't stuck in a buffer) and probably throw ASan or similar at it to see if it notices anything. Of course, it might be something unexpected going on in the test code that you can't reproduce yourself - for which I suppose very carefully finding out how your function should behave is a start.

    When i run your code against the tests and print out the indata, it turns out it does happen for an obviously special test case, so there's a good chance you don't need to dig any further than that.

  • Custom User Avatar

    hello everyone! i'm newby in C and trying to solve this task, but failing in a random test: get SIGSEGV. what could be the reason? (code below)

  • Custom User Avatar

    Sort string1 based on the corresponding character's positioning in string2. So, a comes first followed by b, then n, so banana becomes aaabnn

  • Custom User Avatar

    Approved

  • Custom User Avatar
  • Custom User Avatar

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

  • Custom User Avatar

    CS: last testcase expects {"1":4,"5":1,"10":0,"25":1366087610} but should be { '1': 4, '5': 1, '10': 0, '25': 2397957838778 } as stated 9 years ago. Still applies.

    Also no random tests and no sample tests.

  • Custom User Avatar
  • Custom User Avatar

    Retired.

  • Custom User Avatar

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

  • Custom User Avatar
    • No sample tests

    • Ruby 3.0 should be enabled

    • Desciption should be language-agnostic

  • Custom User Avatar

    Duplicate issue (no sample tests).

  • Custom User Avatar

    Test cases do not work, an Error have been raised or undefined "add" function used in TDD. Only "Attempt" test cases work, so at least this Kata is doable.

  • Loading more items...