Ad
  • Default User Avatar

    10 months ago and nobody fixed it yet? Wow!

  • Default User Avatar

    The similar (probably a little easier) kata "Sum strings as numbers" says

    Python: your solution need to work with huge numbers (about a milion digits), converting to int will not work.

    Can't we have a likewise test with huge numbers in this kata as well?

  • Default User Avatar

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

  • Default User Avatar

    How about the following edge case?

    dotest(2, 100, 102, { 101, 103 });
    

    Should this test return an answer, because 101 is within the range, or should it not return an answer because 103 is out of range?
    It's not clear for me from the decription and examples.

  • Default User Avatar

    it's difficult to find out what it actually is and where from.

    Yes, it was difficult. How do you C++ people debug such things?

    it's an error on your side

    Sure, it was. Yet, if I do similar mistake in other programming languages, I typically get a compiler error.
    I think this is a real disadvantage of C++. Code compiles (and for whatever reason even worked), so how should I find out I made a mistake?
    This time I was lucky, because Codewars uses a different compiler or whatever. If this were production code, it would have gone unnoticed.
    I want to prepare myself for real-world C++ with Codewars. Any additional hints are welcome.

  • Default User Avatar

    I had an interesting issue and would like to know more details.

    All tests passed in my Visual Studio environment, but I didn't pass the acceptance test on CodeWars.
    I pulled the test data out of the acceptance test - but they passed in Visual Studio as well.
    I then tried to reproduce the issue in an online IDE and the online IDE complained that I did not #include for std::unique().
    I #included in Visual Studio and suddenly the tests in Visual Studio had the same results as on CodeWars.

    Now I am wondering:
    Where did std::unique() in Visual Studio come from when I did not #include ?
    What did that version of std::unique() do? Obviously something different.
    Where did std::unique in CodeWars come from when I didn't #include ? Can we change that so we get a compiler error?

  • Default User Avatar

    You gotta love the realism of these Katas. You're given a task and you solve it. All tests pass.
    As soon as you publish it, someone comes and says: "Oh, BTW, this should work for numbers up to 4123987691273896765234765. And those 158 tests, that we didn't give to you before, should finish in under 12 seconds."
    Wonderful kata.

  • Default User Avatar

    Typo: for n as least as large --> at least

  • Default User Avatar

    How many braces am I supposed to put into the equation?
    The test "t", "" (true with no operator at all) has unlimited results, depending on the number of braces to be used: (t), ((t)), (((t))), ((((t)))), etc.

    Reading the other comments, I also wonder what the operator precedence shall be in order to sort out the duplicates.

  • Default User Avatar

    The tests do not have namespaces for their types. I have to use

    using namespace std;
    

    to make the tests work. That's considered bad practice.

    Error message if I don't have that in my code:

    ./tests.cpp:3:23: error: no template named 'vector'; did you mean 'std::vector'?
    void test_cases(const vector<pair<string, char> > &cases)
    
  • Default User Avatar

    I have to

    using namespace std;
    

    otherwise the tests won't work.
    It's considered bad practice to do that. I should not need to make assumptions about the tests.

    If I don't use that namespace, the error is

    In file included from main.cpp:7:
    ./tests.cpp:3:17: error: no template named 'list'; did you mean 'std::list'?
    
  • Default User Avatar

    I can do a

    using namespace std;
    

    in my code to fix it, but that's bad practice.

  • Default User Avatar

    I'm trying the C++ version. The test is fine, but on my attempt, I get

    In file included from main.cpp:7:
    ./tests.cpp:79:13: error: no template named 'vector'; did you mean 'std::vector'?
          const vector<char> originalFull_Data(full_byte_data);
                ^~~~~~
                std::vector
    

    Note that this is in tests.cpp, not main.cpp.

  • Default User Avatar

    "Focus on efficiency" - CPU or memory?