Ad
  • Custom User Avatar

    I could add an additional condition that is AND in the loop which is 0 > openBracesCtr.

    Something like this:
    for(auto i = index+1; i < str.size() && 0 > openBracesCtr; ++i)
    {
    //same as before, but break can now be removed.
    }

    Btw, in my opinion both solutions have similar performance. I guess it's for coders preference on which is more reable. Anyways, thanks for the suggestion. It's good to think a way in tweaking existing solutions. :)

  • Custom User Avatar

    C++ Error.

    I already have the code, however it always throws error when I run the test, I have tested the code in online compiler and it works however, when I use it here it fails. Below is just a simple snippet that will throw error.

    Basic declare then return, just to check. Still it throws error.
    std::unordered_map<std::string, std::string[6]> conjugate(std::string verb){
    std::unordered_map<std::string, std::string[6]> ret;
    ret[verb][0] = "pak";
    ret[verb][1] = "pak";
    ret[verb][2] = "pak";
    ret[verb][3] = "pak";
    ret[verb][4] = "pak";
    ret[verb][5] = "pak";
    return ret;
    }

    Error:
    -isystem /runner/frameworks/cpp/ In file included from
    In file included from /runner/frameworks/cpp/igloo/igloo_alt.h:10:
    In file included from /runner/frameworks/cpp/igloo/igloo_framework.h:12:
    In file included from /usr/include/c++/v1/iostream:38:
    In file included from /usr/include/c++/v1/ios:216:
    In file included from /usr/include/c++/v1/__locale:15:
    In file included from /usr/include/c++/v1/string:439:
    In file included from /usr/include/c++/v1/algorithm:627:
    /usr/include/c++/v1/memory:1585:20: error: object expression of non-scalar type 'std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]' cannot be used in a pseudo-destructor expression
    __p->~_Tp();
    ~~~^
    /usr/include/c++/v1/memory:1483:14: note: in instantiation of function template specialization 'std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]>, void > > >::__destroy<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]>' requested here
    {__destroy(__has_destroy<allocator_type, _Tp
    >(), __a, __p);}
    ^
    /usr/include/c++/v1/unordered_map:520:29: note: in instantiation of function template specialization 'std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]>, void *> > >::destroy<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]>' requested here
    __alloc_traits::destroy(_na, _VSTD::addressof(__p->_value.__cc.second));
    ^
    /usr/include/c++/v1/memory:2625:13: note: in instantiation of member function 'std::__1::__hash_map_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]>, void *> > >::operator()' requested here
    _ptr.second()(__tmp);
    ^
    /usr/include/c++/v1/memory:2593:46: note: in instantiation of member function 'std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]>, void *>, std::__1::__hash_map_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]>, void *> > > >::reset' requested here
    _LIBCPP_INLINE_VISIBILITY ~unique_ptr() {reset();}
    ^
    /usr/include/c++/v1/unordered_map:1361:25: note: in instantiation of member function 'std::__1::unique_ptr<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]>, void *>, std::__1::__hash_map_node_destructor<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]>, void *> > > >::~unique_ptr' requested here
    __node_holder __h = __construct_node_with_key(__k);
    ^
    note: in instantiation of member function 'std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6], std::__1::hash<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]> > >::operator[]' requested here
    ret[verb][0] = "pak";
    ^
    In file included from
    In file included from /runner/frameworks/cpp/igloo/igloo_alt.h:10:
    In file included from /runner/frameworks/cpp/igloo/igloo_framework.h:22:
    In file included from /runner/frameworks/cpp/igloo/external/snowhouse/snowhouse/snowhouse.h:5:
    In file included from /runner/frameworks/cpp/igloo/external/snowhouse/snowhouse/constraints/constraints.h:12:
    /runner/frameworks/cpp/igloo/external/snowhouse/snowhouse/constraints/equalsconstraint.h:25:26: error: invalid operands to binary expression ('const std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > > >' and 'const std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6], std::__1::hash<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]> > >')
    return (m_expected == actual);
    ~~~~~~~~~~ ^ ~~~~~~
    /runner/frameworks/cpp/igloo/external/snowhouse/snowhouse/assert.h:77:15: note: in instantiation of function template specialization 'snowhouse::EqualsConstraint<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > > > >::operator()<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6], std::__1::hash<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]> > > >' requested here
    if (!expression(actual))
    ^
    /runner/frameworks/cpp/igloo/external/snowhouse/snowhouse/assert.h:71:9: note: in instantiation of function template specialization 'snowhouse::Assert::That<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6], std::__1::hash<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]> > >, snowhouse::EqualsConstraint<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > > > > >' requested here
    That(actual, expression, no_file, no_line);
    ^
    note: in instantiation of function template specialization 'snowhouse::Assert::That<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6], std::__1::hash<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > [6]> > >, snowhouse::EqualsConstraint<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > >, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > > > > > > > >' requested here
    Assert::That(conjugate("caminar"), Equals(sol));
    ^
    2 errors generated.

  • Custom User Avatar

    Please add an instruction that the concatenated columns are separated by space(' '). In the sample test case it will pass even if space separator, but if they do attempt final answer it would fail because of the missing space separator

  • Custom User Avatar

    Fix the C++ version, give complete details about the number range on which the correct response should be. There is not enough data to do this, just guessing on the correct number range based from the pre-loaded sample test cases.

  • Custom User Avatar

    For C++, test is INCORRECT for should_allow_multiple_correct_guesses:

    It(should_allow_multiple_correct_guesses)
    {
        Guesser guesser(10, 2);
        for (int i = 0; i < 10 /* THIS SHOULD BE 2 */; ++i)            -->PLEASE CORRECT THIS
            Assert::That(guesser.guess(10), Equals(true));
    };
    

    When I'm attempting the final solution it also throws error for that same test case and the Random Test Case, please verify if test inputs are correct. I have tested my code in google test and everything is passing using corrected similar tests as in the examples.

  • Custom User Avatar

    Already did the trimming of whitespace at the end of return string. It still fails...

  • Custom User Avatar

    Hi,

    Im solving the problem using C++. But Complex Test Case always failed even though Expected is the same as my Actual. See string below:

    Expected: equal to SOS! THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
    Actual: SOS! THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.

    Did anyone encounter this or I am missing something?