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.
You're misreading the two tests and assuming that they're the same but expecting two different results. They're not the same, hence the different expectations.
If you don't yet see it, try replacing the call operators with add operators and add newlines after the semicolons - thus presenting it in a more familiar format and also forcing you to read it as part of editing it.
I don'tknow about C++ tests, but at least in javascript:
There is no
a(3)
call there.Do these tests contradict each other?
must_be_able_to_store_curried_functions
auto a = add(1)(2); a(3) == 6
Expected: equal to 6
Actual: 3
//////
must_be_able_to_store_values
auto a = add(1)(2); a(3); a == 3
auto b = add(3)(4); b == 7
Test Passed
yes, with closure
@brodiemark, that error message is both accurate and fair. You defined a repr that is indistinguishable from int and then your complaint is that your repr is indistinguishable from int. It's also explicitly stated in repr's docs that you shouldn't do that.
Okay, I see. Thank you.
Your solution returns the number passed in, so
add(1)
returns1
- if you then doadd(1)(2)
, you're trying to call the number1
as a function, which causes the error.Can not run it in Python 3.11, I just keep getting this error:
Unexpected exception raised
Traceback (most recent call last):
File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper
func()
File "/workspace/default/tests.py", line 8, in _
test.assert_equals(add(1)(2), 3)
^^^^^^^^^
TypeError: 'int' object is not callable
This comment is hidden because it contains spoiler information about the solution
That might be the intention, but the quotes don't seem to be displayed in some situations.
If you remove the eq method from my solution in "View Solution" above, you'll see test results as in my first message.
If you return a string instead of a number the error message is like this in Python:
And you should note the quotes around the first value. Unless I'm missing something.
Great problem! Learned a lot.
Suggestion (for Python): The tests can fail with the following unhelpful results:
1 should equal 1
3 should equal 3
6 should equal 6
What's happening here is that one of the 1's is an integer and the other is a string. It would be nice if the tests detected this and pointed it out.
Task clearly states that we need to create a function, yet all of the solutions are classes. Its nonsense.
Kotlin translation
Uhhh.... 4 kyu?
Loading more items...