Ad
  • Custom User Avatar

    @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.

  • Custom User Avatar

    Okay, I see. Thank you.

  • Custom User Avatar

    Your solution returns the number passed in, so add(1) returns 1 - if you then do add(1)(2), you're trying to call the number 1 as a function, which causes the error.

  • Custom User Avatar

    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

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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.

  • Custom User Avatar

    If you return a string instead of a number the error message is like this in Python:

    '1' should equal 1
    

    And you should note the quotes around the first value. Unless I'm missing something.

  • Custom User Avatar

    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.

  • Custom User Avatar

    Task clearly states that we need to create a function, yet all of the solutions are classes. Its nonsense.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    Oh, thank you. I was starting to overload all the other operators. Didn't thought about <<.

  • Custom User Avatar

    The [unsupported type] thing is a problem with the C++ testing framework. You can fix the messages by adding operator << to your class:

    std::ostream& operator<<(std::ostream& os, const Add& add) {
      return os << add.get_n();
    }
    

    As to why it returns wrong result, I do not know yet.

  • Custom User Avatar

    I pass the first 6 tests (a_single_call_should_compare_equal_to_the_number_passed_in, must_be_able_to_store_curried_functions, must_be_able_to_store_values, must_be_usable_in_a_normal_addition, must_be_usable_in_a_normal_subtraction and should_pass_some_example_tests). In particular, I pass all examples given in the kata-instruction.

    However, the last test (should_pass_some_tests_with_random_data) fails with

    Expected: equal to 1313
    Actual: [unsupported type]

    I don't know what needs to be supported in addition. Am I supposed to figure this out on my own?

  • Custom User Avatar

    JavaScript Completions 17573

    Yes, it is.

  • Loading more items...