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.
cool one
literally the same kata
https://www.codewars.com/kata/525f4206b73515bffb000b21/lua
No idea, hard to tell. Sorry.
Pass 120 tests for less than a second but got timeout. What did I miss?
If a or b is empty ("") you have to make them 0. Otherwise you will get a Parse Error. Please Fix that.
I think that empty input strings should be trated as 0. But ideally I think that empty string inputs should be removed from tests.
What should I return, if the input string is "" ?
Where is no word for that case. Should I return the non-empty string? Should I throw an error. How can I guess?
my code have 23 lines and it works but it slow. I don't know how optimize this. Python
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
Loading more items...