8 kyu
Sum The Strings
28,246 of 57,899K-Calderon-ASC
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Oh, I made such a construction for a function, but it turns out there are so many very simple solutions in one line...
Found this enjoyable. Sneakily trickier than expected.
Very simple
Rust translate
there is mistake still. As task we have function sumStrings(a, b) {}, but in tests it has been using sumStr(a, b) !!!
It seems like you are seeing some old version code, that is the most likely thing I could come up with. (Try clicking
reset
to see the newer version) Otherwise, JS is already updated to latest version and so is the description, closing!Hi! It seems there is a mistake in random tests. The instructions tell us that arguments will be strings so I check with the empty? method, but on attempt I got NoMethodError because one of the arguments is a float.
In what language?
It's Ruby.
fixed, thanks for your report
This comment has been hidden.
Not a kata issue. Because it enters the first if and your code returned "" instead of "0". Read the description again.
00000
Caught std::exception, what(): basic_string::_M_construct null not valid //// What does it mean?
good test
This comment has been hidden.
This comment has been hidden.
expected '9 ' to equal '9'
Your solution is wrong, and it does not work in vscode either. It adds a space at the end, which should not be there.
Bugs in your solution are not a kata issue.
This comment has been hidden.
you failed to test an instance where either a or b could be ""
OP solved it, closing
This comment has been hidden.
This comment has been hidden.
Depends entirely on your lang
I don't see how you could do this within programming as a whole. Normally you'd use an array if you wanted to work on multiple values at once, so this would require a real quirky solution or use of a normally redundant method to work.
Scala translation
.
Couldn't see what the input of the only test that was failing was, so I had to unlock solutions. Does anyone know how to see inputs for all tests for katas?
Printing them: https://docs.codewars.com/training/troubleshooting#print-input
You can always
print
to the terminal/console by including a print statement in whatever language you are working in - sorry I don't know Javascript, but whatever you use to print stuff on screen usually like in a Hello World! program - just include it in the main body of your function, and include the name of the argument that the kata is using.You might find the following document useful also - I've linked the part about printing the input: Troubleshooting - codewars
No possibility to use itoa. I am newbie to Codewars on I dont know if is possible to change compiler options, to allow usage of functinos like this.
Thanks
itoa()
is not in standard C or C++, so you'll have to use something else. it's not in GlibC either as far as i know so compiler flags will not help you thereCOBOL translation (author is inactive).
approved
This comment has been hidden.
Because this is syntactically incorrect in Python.
This comment has been hidden.
you can perform a check to see if either of them are empty
Man, the solution has to be a String...
C translation (author gone)
Approved
This comment has been hidden.
your code has more lines than a "legitimate" solution ^^
I've tried solving this in Swift and its running well on my xcode but it keeps throwing error here...please get this fixed
The kata seems to work fine in Swift, why do you think it's broken?
Please see if anything here helps: https://docs.codewars.com/training/troubleshooting
🤷
Hello, everybody! I don't understand how to convert empty string into integer in C#. I tried checking it with .IsNullOrEmpty(), but it doesn't help. Could anyone give an advice?
What do you do once you've determined that a string is empty (e.g. with the method you describe)? Hint: the description tells you what to do.
Thanks for helping!
C# Translation
Approved by someone
This comment has been hidden.
You aren't missing anything. One of the benefits of codewars is that you can see other people's solutions. If you see something you don't understand in someone's solution, you can research it and learn something new. So, you have 3 things to google now.
This comment has been hidden.
Please don't post solutions in Discourse.
can u tell me how to delete this
Hover on your message -> "Remove" button
C++ translation
Coffeescript && Crystal (author inactive)
This comment has been hidden.
This comment has been hidden.
same issue how do we solve it...
This comment has been hidden.
Last line of the kata's description.
some
This comment has been hidden.
Read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
the discription on this is incorrect, it says the inputs will be strings, but they are strings or integers.
Fixed.
This comment has been hidden.
this kata seems to be broken. The test cases don't run (at least on python)
Have just completed it in Python, and 2,700+ others have too - doesn't look like there's an issue. Can you give more info if you think there's a problem?
EDIT: Looking at comments below, looks like an issue with Python versions < 3.8
Yeah, it seems there is a name error in the test cases: name "Test is not defined". When call the function for my own test, it works properly.
Click reset, try again. It should work now.
now it works, but now it what's boggles my mind is that I don't get a pass on test casses when one of the strings are empty. even tough when I pass the function myself sum_str("","5") I get the result 5. When I run the test I always get the result "None should equal 9" or "None should equal "(instert number there). I don't think I wrote the code wrong, because it works(I think).
Read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
Thank you @Chrono79. It helped me to understand my issue.
@K-Calderon- your kata has an issue with TDD that raise error about variable Test is not defind. We can't complete this kata.
Even when using known solutions I get the message "Test is not defined."
This would be Python.
for 3.6, codewars_test is imported as both
test
andTest
, while for 3.8 it is imported only astest
I do wonder if this is intentional because it probably breaks many kata.
Switch language version to Python 3.8.
by default is set to Python 3.8 and still same issue. can't switch back to 3.6 since it's disabled.
@barakah I believe you are referring to the example tests? those will still have their old content until you click the reset button or manually edit. the actual test code is still updated regardless of whether you reset, I think.
@natan Thanks for your comment, even I reset kata the issue was undefined variable but after your comment I tried again and it's working fine. I believe someone has fix the issue
This comment has been hidden.
This comment has been hidden.
Not a kata issue. If you're having a problem with the site, raise an issue on CW github with an explanation, screenshots, messages from the browser console, anything else that could be useful.
Ruby translation kumited :) please check and approve ~~
This comment has been hidden.
if so sum_str() '0' wtf? whts wrong with ths kata man?
Read the instructions again, your function returns numbers (
0
is a number,'0'
is a string). And mark your post as having spoiler content when you post code like you did, please.This comment has been hidden.
had the same issue. plz explain someone.
ok
Create a function that takes 2 positive integers in form of a string as an input, and outputs the sum (also as a string):
In the test you are giving empty strings. Empty strings is not positive iteger!! Please make a correct description!
Julia translation
Approved
This comment has been hidden.
Well, your first if is wrong then.
Specifically,
So, let's say that '' and '' were passed in.
The first statement turns out to be true, so it will run that statement, and will return '' (which is b).
The if statement puts conditions on top as priority, and will exit once one correct statement is present.
That explains the reason - the dual-check is skipped because the condition before it passes. The best way to solve it is to check each condition starting from the most demanding to the least.
'Looks like you've solved it'
This comment has been hidden.
Read the error message:
Read the instructions again:
Change your code to address that.
oh sorry about that and thank you for your answer
This comment has been hidden.
Not an issue. Your logic is incorrect.
Haskell translation
This comment has been hidden.
Paste your code, mark your post as having spoiler content. Use proper markdown I did solve the kata with no problem in python.
When you receive empty strings do you return
""
or"0"
? Because it seems you're returning the former instead of the latter one.I return "0"
Then you should post your code with a spoiler tag in the comments because Python version is working correctly.
Issues without relevant content are not actionable issues, non actionable issues are not issues.
Approved
please tell what will happen when a, b is empty
Read the descriptions ;-)
Python translation kumited. If you wish to approve it.
; ) )