Ad
  • Default User Avatar

    @Pamblam, I think he talks about consistency.
    It would make more sense for iteration function (callback function) to return a promise instead of accepting a callback argument.
    Or, on the other hand, slowLoop could accept a callback instead of returning a promise.

    promises are basically useless without at the very least a "then" callback.

    What about async functions?

  • Default User Avatar

    C++ sample test is broken. Throws errors.
    For example:

    class ArcParabLen
    {
    public:
      static double lenCurve(int n) {
        return 0.0;
      }
    };
    

    results in

    -isystem /runner/frameworks/cpp/  error: call to 'abs' is ambiguous
        bool inrange = std::abs(act - exp) <= 1e-6;
                       ^~~~~~~~
    /usr/include/stdlib.h:775:12: note: candidate function
    extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
               ^
    /usr/include/c++/v1/cstdlib:159:44: note: candidate function
    inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
                                               ^
    /usr/include/c++/v1/cstdlib:161:44: note: candidate function
    inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
    

    Did you forget to #include <cmath>?

  • Default User Avatar

    Should be fixed now.

  • Default User Avatar

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

  • Default User Avatar

    I understand the kata's description

    return the first two values (parse from the left please) in order of appearance

    in the following way:

    1. The values should be at different indexes in the list.
    2. If there are several pairs that sum up to the target sum, the one that appears first in the list should be returned.

    So, in the mentioned test:
    The pair [5, 5] with indexes 1 and 1 violates #1.
    The pair [5, 5] with indexes 1 and 5 violates #2, because [3, 7] with indexes 3 and 4
    appears earlier (both values of the [3, 7] pair appears before the second 5 of the [5, 5] pair).
    This test is also explained in the kata's description: see the last example.

    Hope that helps.

  • Default User Avatar
  • Default User Avatar

    Looks like a typo:

    If the user tries to guess more than the limit the function show throw an error

    I think should was supposed to be there instead of show.

  • Default User Avatar

    I think this kata (and other 'Vasya' katas as well) is just copy-paste of http://codeforces.com/problemset/problem/208/A
    I don't know if Codewars has any policy about such things, but I personnaly don't like it.
    The description should at least have a link to the source.

  • Default User Avatar

    That's awesome! I like the way it all began with a comment.
    I hope no one's feelings are hurt.

  • Default User Avatar
    It's not from the kata but from CW when there is an error in the code.
    

    Why are you so sure?
    Why can't you spend a minute and try to understand what the problem is here?
    All your messages are like 'You are wrong. Go away'. That's a good reason to downvote.

    If you have gotten a bad result the info would have been the same as in Python.
    

    Oh, really?
    Let's try this solution:

    class SqProd2Sum
    {
    public:
      static std::vector<std::pair<long, long>> prod2Sum(long long a, long long b, long long c, long long d)
      {
        return {{0, 0}};
      }
    };
    
    Expected: equal to [ [unsupported type], [unsupported type] ]
    Actual: [ [unsupported type] ]
    

    Ah... Seems like something is wrong with my code...
    But can you say what?

    All what you need to do is to convert a vector of pairs to something what the test framework can handle.
    For example, converting it to string should work:

    std::string str(std::vector<std::pair<long, long>> v) {
      std::stringstream s;
      s << "{";
      for (size_t i = 0; i < v.size(); i += 1) {
        if (i > 0) {
          s << ", ";
        }
        s << "{" << v[i].first << ", " << v[i].second << "}";
      }
      s << "}";
      return s.str();
    }
    
    void testequal2(std::vector<std::pair <long, long>> ans, std::vector<std::pair <long, long>> sol) {
        Assert::That(str(ans), Equals(str(sol)));
    }
    

    Using testequal2 instead of yours testequal yields the following output:

    Expected: equal to {{1, 7}, {5, 5}}
    Actual: {{0, 0}}
    

    And that's what I would like to see.

  • Default User Avatar

    I understand why I get that.
    The problem is that it's useless.
    I expect to see more details on why the results are wrong.
    For example Python tests output looks like

    [[0, 20000], [5600, 19200]] should equal [[0, 20000]]
    

    Which is a way better.

  • Default User Avatar
    e and f positive integers
    

    Zero is not a positive integer.

  • Default User Avatar

    Tests output for C++ is not very informative:

    Expected: equal to [ [unsupported type], [unsupported type] ]
    Actual: [ [unsupported type], [unsupported type], [unsupported type], [unsupported type] ]
    
  • Default User Avatar

    Could you describe what the problem is exactly with the part 2?

    Your solution should work, but it will only work if data.length is 32.
    To complete the kata you will need to generalize the algorithm to handle any length (multiple of 8).

  • Default User Avatar

    It seems that the idea here is that a solution should be able to sort any array, i.e. object arrays (Object[], String[], Integer[] and so on), int[], long[], float[], double[] and so on.

  • Loading more items...