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.
Also in
C++
,Python
and originalJS
(probably some others)So we have to two options here:
And because this kata is 4kyu, then the second solution seems more reasonable!
for
"8" + "9"
, this will allocate0
bytes of memory, while3
are needed.what makes your code crash however it the fixed test with an empty string (which should not exist, but that's a separate issue already reported here
Your solution has a bug. For some inputs it returns a non-freeable buffer, and tests crash on attempt to free it.
C
testcase: strsum("99999999999999999999999999999", "9999999999999999999"), "100000000009999999999999999998"
My code passes when I use the same testcase on the sample tests, yet I receive a "Caught unexpected signal: SIGSEGV (11). Invalid memory access." when attempting the generic tests.
What could be the problem?
My dumbass tought he could just convert to long long, make the sum and convert back to string.
Amazing kata!
The two functions are not the same; the second code nests the
y
loop inside thex
loop, causing different behavior, while the first runs the loops separately.This comment is hidden because it contains spoiler information about the solution
langs do not work like that, at least 4 this level
try another algorithm
They are totally not identical, if you open your eyes you will see a difference between them :D
Leading 0's are not perrmited, as no "real" numbers have them (except 0 itself).
Your solution does have leading 0's, "03" != "3"
This comment is hidden because it contains spoiler information about the solution
This kata is great !
This kata is great ! i scratched my head so hard trying to code a simple addition xD
You should treat each string as a representation of a base-10 integer. So, "0" -> 0 and "5" -> 5, so the expected answer is
5
and not the addition of 2 strings which yieldNaN
.I think if leading zeros are allowed, it makes sense to say so in the condition or show it in the example for the task.
Loading more items...