Ad
  • Custom User Avatar
  • Default User Avatar
  • Custom User Avatar

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

  • Default User Avatar

    Number of occurences
    and
    Find the matching parenthesis

    have the same problem (especially the latter where extending the prototype doesnt make much sense)

  • Custom User Avatar

    I suggest to change it in all languages to acheieve consistency! This also applies to several katas whereby a method of a class is used instead of a standalone function.

  • Custom User Avatar

    I personally do not care about invalidating solutions to an easy kata if this would mean improving user experience with the kata. I think that improvements in consistency, maintainability, user experience, and overall quality are worth invalidating solutions en masse, because I think it causes no negative impact neither on users, nor on the kata in question.

    But in this case I thought that only JS requests for prototype extension and other languages use free functions. Now Chrono explained it's not the case, so I am not sure if it's worth changing in JS, or in all languages.

  • Default User Avatar

    we could make this backwards compatible as well, to avoid invalidating 60,000+ solutions, but on the other hand new solvers will be confused when seeing the solutions page

  • Custom User Avatar

    Ruby, Swift and TypeScript at least.

  • Custom User Avatar

    I am seriously tempted to get rid of the prototype extension and make the solution just a free function. It causes more trouble than it's worth, and there are also other kata which can teach how to do extensions.
    Do any other languages follow the pattern of extending a string type?

  • Default User Avatar

    Fork

    • Node 18+ && chai assertions
    • improved assertion messages
    • initial code now extends the prototype with Object.defineProperty not to teach bad practice (extending a built-in is already bad practice, but too late for that...)
    • to hopefully reduce the frustration in the comment section:
      ** added some indications in the initial code
      ** checks that the user indeed extends the prototype (in case the user erases the initial code and rewrites a normal function)
  • Default User Avatar

    first point:

    the provided clang installation appears to find a definition of strdup() which ought to return an int,

    When the compiler encounters a function call for which it does not find a function declaration, it assumes the function has this prototype: int func_name ().
    strdup() is sadly not yet part of standard C (it will be added in C23). This is why the compiler does not find it in <string.h> : it is a POSIX extension. you have to #define _GNU_SOURCE before #include <string.h> to make it visible:

    #define _GNU_SOURCE
    #include <string.h>
    

    second point: your code is almost correct, but has 2 mistakes:

    • you are not handling empty strings correctly,
    • you are adding a trailing space at the end of the string
  • Default User Avatar

    what would be the point of passing jaden_case in parameter if you were expected to return a fresh new string ? you must write to it, as indicated in the initial code, not reassign it, which is not visible by the caller.

    (also note that you forgot to allocate a byte for the '\0' terminator here)

  • Custom User Avatar

    how could this be the case then? expected 'How Can Mirrors Be Real If Our Ey Aren\'t Real' to equal 'How Can Mirrors Be Real If Our Eyes Aren\'t Real'

    How is Ey supposed to end up being Eyes, very random out of nowwhere

  • Custom User Avatar

    No, and please read the posts below or provide some proof when you say something is broken:

    JavaScript Completions 60647

    Your code is wrong.

  • Custom User Avatar

    broken on Javascript