Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
There is no such test, but you solved it already. What was the problem?
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' }
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 withNULL
pointers; and the tests will handle thoseNULL
s safely for both comparison and composing the assertion message. your code no longer crashes now.you have an array of pointers,
words_array
. it contains as many elements as there are words in the string, but initially (whenwords_to_array()
is called), it does not contain anything meaningful; you have to fill it with strings allocated on the heap (i.e. withmalloc/calloc/strdup()
)you realized your mistake but forgot to close your question afterwards
OP solved the kata
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
This comment is hidden because it contains spoiler information about the solution