Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • 13605398?v=4
  • Profile-pic

    Usually I think codewarriors add what is needed and lots of guys passed the kata as it was and nobody complained.
    I just added "#include cmath". Thanks!

  • Profile-pic

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

    class ArcParabLen
      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>?

  • Profile-pic

    Should be fixed now.

  • Profile-pic

    Never use recursive method. It's unsafable with overflow memory stack.

  • 706078?v=3
  • 17554627?v=3

    Technically correct; however, the original list was mutated. Try deep-copying the list that was passed in, then work with those values instead. :)

  • 24650632?v=4
  • Profile-pic

    And I also learned that letters due to their unicode values can be useful in some situations. Thanks

  • Profile-pic

    I found this pretty clever guys.. :)

  • 1228739?v=3

    In the example tests just test against fixed values. If the return type is too complex for a one-line cr_assert_equal add a test function (which can also provide better error messages and cleanup):

    #include <criterion/criterion.h>
    unsigned long long* eval(unsigned long long n);
    void test_eval(unsigned long long input, unsigned long long expected1, unsigned long long expected2)
        unsigned long long expected[2] = {expected1, expected2};
        unsigned long long *actual = eval(input);
        if (actual)
            cr_assert_not(memcmp(actual, expected, sizeof(expected)),
                "eval(%llu) should return {%llu, %llu}, actual: {%llu, %llu}",
                input, expected1, expected2, actual[0], actual[1]);
            cr_assert(actual, "eval(%llu) should not return NULL", input);
    Test(eval, should_pass_all_the_tests_provided)
        test_eval(2134563, 246, 1353);
        test_eval(20468, 20468, 0);

    Having this test function in the example tests makes it clear for everybody what happens, e.g. if the result is freed in the end.

  • 24660964?v=3

    It is in the preloaded section, How can do it properly then ?

  • Profile-pic

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

  • 22766301?v=3

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

  • Profile-pic

    Modulo (%) is very slow. To find out if a value is odd or even, just extract the lowest bit. Like this: x & 1
    so, your "is_odd"-function above could just return v & 1.

  • Loading more items...