Ad
  • Default User Avatar

    i'm not sure if it's in the scope of the kata. the description says:

    All letters will be lowercase and all inputs will be valid.

    I just added better messages to the C version and i saw that the reference solution cannot handle empty strings / strings consisting entirely of spaces

  • Default User Avatar

    unclear issue, and 1,000+ Go completions

  • Default User Avatar

    This is not an issue, this is a question ;-)

    Your code is incorrect and you have to debug it
    I see several mistakes :

    • you are incrementing the word count at each space that you encounter, but words can be separated by more than one space : "a b"
    • you are allocating a fixed size buffer (malloc(256)) without being sure it will be enough in the worst case scenario
    • there is a mismatch between the type and the size you allocate for it there:
      char (*words)[len] = malloc (sizeof(char[word_count][len]) );
      
      words is a pointer to a char array of length len
      you allocate the size of an array of length word count of array of length len of char
      also note that you forgot to add +1 for the nul terminator

    Your approach is too complicated. You dont need to allocate a 2D array to store every word. You can solve this in only 1 pass of the input string, keeping track of the current longest word as you go

  • Default User Avatar

    same here.

    "
    The expression (as strings) (res) == ("taxi") is false: actual=taxi expected=taxi.
    "

  • Custom User Avatar

    In C i've get random tests passed, but only 1 line is breaking and i dont understand why...

  • Custom User Avatar

    Spoiler flag for explanation to a question in solution right ?

  • Custom User Avatar
  • Custom User Avatar

    You sure it's 7kyu for C ?

  • Custom User Avatar

    Don't give free hints and let people solve the kata by themselves, that's part of the learning process, just like it has been for you. I marked your message as a spoiler.

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

    if function is returning non void type (int , char , whateva) than compiler will generate an error if it meets end of the fucntion "}" without return statment