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.
bruh
I am blown away by the solution :D
If you're gonna add type hints, go all the way:
Also, the
# your code here
is 100% optional, I personally find it unnecessary. The "should be runnable" thing would be nice though.It actually took me quite a bit to understand why :'D
Thanks
your code is almost correct now, but you are not handling an empty array correctly
So it is guaranteed that there wont be spaces inside the words
you do not allocate enough memory.
count
is the length of the input array, i.e. the number of strings. your string will always require more memory than that, for example if you join"ab"
and"def"
you need 2 ("ab") + 1 (space) + 3 ("def") + 1 (nul terminator) = 7 bytes. you need to calculate the correct buffer size before allocating memory.what is the point of your
while (result_index < char_num)
loop ? you already have the correct string at the end of the enclosedfor
loop. Having thewhile
loop makes your program concatenate the same string several times, so you write e.g."a b c d a b c d"
instead of just"a b c d"
(and your buffer is not large enough for that, hence the segfault)I am attempting this in C, the single string test case always fails with seg fault.
I tried to return *words when count==1, not working. Can anyone be so kind so as to explain this to me?
i'm new to programming and i was wandering how can you write the codes in a comment like you did with that box and colors? i tried copy and paste but it comes as a text and without than box? thanks in advance!
Very simple :D
Yes, it work now.
@monadius, thank you very much!
I updated Dart random tests. Now
reduce
should work.Dart random tests called the solution function with an argument of type
List<int>
. I changed this type toList<num>
. Dart allowsList<int>
whenList<num>
is expected because all generic parameters are covariant in Dart and soList<int>
is a subtype ofList<num>
. On the other hand,List<E>.reduce(E combine(E, E))
has a contravariant argument (the return value ofcombine
). That's why it was impossible to usereduce
before (all generic arguments offold
are covariant so there were no issues with it).*Post edited for not being helpful*
This comment is hidden because it contains spoiler information about the solution
Loading more items...