Ad
  • Custom User Avatar

    can someone help me with how we arrive at that pattern?

  • Custom User Avatar

    @sgelmans91

    Just counting all combinations doesn't work because values eventually overlap between different letter combinations; the shortest example is LIIIII == 55 == XXXXXV, and this is why solve(6) == 83 != 84.
    The whole kata is about thinking and finding the pattern.

  • Custom User Avatar
  • Custom User Avatar

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

  • Custom User Avatar

    Thank you!

  • Custom User Avatar

    Hi newmaidumosa,

    yes, it works fine.

    Don't forget, that "WORK" is a string literal and constant. Therefore this memory block is immutable (read only). In this case you pass in const char* instead of char*. And you get Segmentation fault trying to change it.

    For purpose of this kata, the input parameter shoud be a pointer to the char array and not a pointer to the string literal.

  • Custom User Avatar

    Does this actually work properly? or is it a case that it is just written to pass the test here?

    I am new to C, but it seems like this would only work with an array of chars rather than an actual string?

    I am grateful for any explanation. I am new to this so bear with me.

    When I run:

    int main(void)

    {

    char test[5] = "WORK\0";

    printf("%s <-- array of chars\n", toLeetSpeak(test));

    printf("%s <-- string literal\n", toLeetSpeak("WORK"));

    return 0;

    }

    ~/workspace/extra/ $ ./leet

    W0RK <-- array of chars

    Segmentation fault