Ad
  • Custom User Avatar

    Not a kata issue, I've just submitted a solution in C. Remember to cast to the right type during computation

  • Custom User Avatar

    If it bothers you, you are most likely writing wrong code. The point of doing this is to prevent careless users who assume the memory to be zeroed (a common culprit is the first call to strcat()), or who forget to nul-terminate their strings, to pass the tests when they should not. In general, you should treat output parameters as if they could initially contain anything, unless the function's documentation says otherwise.

  • Custom User Avatar

    I can both confirm that the submitted solutions still work, and confirm that it's normal if you're not finding arguments on the stack!

    You might want to make sure you're reading about the actual Linux calling convention on x86-64, not 32-bit/i386 calling convention. The correct one is also known by other names like 'System-V AMD64 psABI'.

    Edit: Looks like you solved it already. Well, I guess it's a tip for future readers.

  • Custom User Avatar

    Could you post your original solution with a spoiler flag here? In general, you can always use https://c.godbolt.org/ to see the generated assembly.

  • Custom User Avatar

    The C compiler on Codewars follows the Linux calling convention. I recommend to solve some NASM katas to understand this convention.

  • Custom User Avatar

    Submitted solutions still work and there are no major issues with tests.

  • Custom User Avatar

    Good job on solving it by yourself! I'll mark the question as resolved.

  • Custom User Avatar

    Honor points are not the same thing as rank points. Both concepts are explained in the documentation.

  • Custom User Avatar

    Yes. You can adjust the filters and you will see what you need.

  • Custom User Avatar

    This is unfortunately a disadvantage of the fact that every Codewars kata can have only a single rank, shared among all languages. Sometimes it happens that a kata which is very easy in JS or Python is translated into C and is significantly more difficult in a language of lower level. Unfortunately, we have to live with this. But hey, choosing C to solve a kata we know what we signed up for, right? :)

    Having said that, I would recommend taking a look at other solutions after completing the kata. While indeed it might be not totally easy in C, the solution could be much simpler than your current code. Study other solutions, learn something new!

    Cheers!

  • Custom User Avatar

    Did you test your code in your VSCode with n=0?

  • Custom User Avatar

    Yeah sorry to say that, but there's more than one thing wrong in your solution :)

    • sizeof(src) and sizeof(src)*count do not work the way you think, and cause your buffers to be waaay too small
    • return ""; will cause crashes for some inputs
    • strcat(clean_string, "\0"); is either wrong, or redundant (depending on what's already in the clean_string)

    Feel free to join Codewars Discord and ask for help in #c channel, definitely there will be someone willing to help!

  • Custom User Avatar

    I positively confirm it correctly works for C.