Ad
  • Custom User Avatar

    There is no such test, but you solved it already. What was the problem?

  • Default User Avatar

    btw, you have an off-by-one allocation error there: you need 5 bytes to store "word", don't forget the nul-terminator that marks the end of the string: { 'w', 'o', 'r', 'd', '\0' }

  • Default User Avatar

    yeah, it's complicated to provide better feedback because in C you usually cannot check whether a given pointer is valid or not. so the tests will compare the random pointers in words_array and it's likely to lead to a segfault.

    that being said, i just updated the tests to be more user-friendly: words_array will be initially filled with NULL pointers; and the tests will handle those NULLs safely for both comparison and composing the assertion message. your code no longer crashes now.

  • Default User Avatar

    you have an array of pointers, words_array. it contains as many elements as there are words in the string, but initially (when words_to_array() is called), it does not contain anything meaningful; you have to fill it with strings allocated on the heap (i.e. with malloc/calloc/strdup())

  • Default User Avatar

    you realized your mistake but forgot to close your question afterwards

  • Default User Avatar

    OP solved the kata

  • Custom User Avatar

    Could you explain how you got 1201, because 2110 is the correct answer. You should make it so the digits are sorted in descending order (essentially a greater number comes before a lesser number, and we can see that your answer is incorrect as 1 comes before 2, but 2 is a greater digit

  • Custom User Avatar

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