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.
Not a plain comment, but a docstring. Don't really see many of those on CodeWars, HackerRank etc.
Why second ":" though, you are not specifying steps?
for single line comments you could use symbol '#'
I don't think the idea here was to use signed binary integers.
I decided to use the '-' to keep things "codewars legible" if that makes any sense.
negative numbers in binary doesn't have '-', read about that
But you used a docstring!
Yes,
1+2+3
and6
are equal. In that example you will get an error with the text"Error! 1+2+3 is 6 after all. 6 is the one and only perfect, triangular number."
.The top solutions make it look so simple! I suppose it is.
Longer than it needed to be. @dibbs7x3
Revised solution that accounts for negative numbers.
Version 1. This passes the tests but is a false solution since it doesn't allow for negative numbers. See my other solution.
The ASSERT_NOT_EQUALS description confused me a bit. It compares 1+2+3 and the integer 6.
These are equal, so shouldn't it fail? Or does it compare the expression without evaluating?
How does that even work? Like they are able to circumvent the code by gaming the tests?
Would cheating be instances where the tests are not functioning, or is it more of a way of breaking the spirit of the exercise?
I'm new to codewars and find it confusing why anyone would cheat... wouldn't that just defeat the whole purpose of practicing...
Negative test case needed.
OR
Include in description: (a + b) = positive integer
Should specify that the numbers will add up to a positive integer. If not, the tests need to include some negative numbers.
There are a few ways to handle the negative.. the top one is below by @hassan02. You can also do it using some conditions for how to slice the end string.
Still. it probably needs that addition.