Ad
  • Default User Avatar

    OP solved the kata; issue not reproducible with his code.

  • Custom User Avatar
    • These objects
    std::mt19937 engine{std::random_device{}()};
    auto genNumber = std::bind(std::uniform_int_distribution<int>{1, 100}, engine);
    

    should be defined in the Describe(RandomTests) body, and not inside generateRandomInput method. This change will let you simplify the generateRandomInput like this

    std::pair<int, int> generateRandomInput() {
        int n = genNumber();
        int limit = n + genNumber();
        return {n, limit};
    }
    
    • You should check the margins of values for n and limit in other translations
    • It(exampleTests) still has no assertion messages
  • Custom User Avatar

    Looks okay, but I think it needs few corrections:

    • You shouldn't create a new RNG engine every time you want to create a random input. Move the std::mt19937 engine{std::random_device{}()}; statement to the Describe(RandomTests) body under private: section and remove them from methods.
    • I believe, you don't need the reference solution in the test cases. If you rewrite your problem generator as
    std::pair<std::vector<std::string>, std::vector<std::string>>
    generateRandomInput() {
        std::vector<std::string> randomInput;
        std::vector<std::string> expectedResult;
    
        auto genNumber =
            std::bind(std::uniform_int_distribution<int>{0, 20}, engine);
    
        int res = 0;
        for (int i = 0; i < genNumber(); i++) {
            std::string randomString = generateRandomString(genNumber());
            randomInput.push_back(randomString);
            if (randomString.size() == 4) {
                expectedResult.push_back(randomString);
            }
        }
    
        return {std::move(randomInput), std::move(expectedResult)};
    }
    

    you can then use it as

    auto [input, expected] = generateRandomInput();
    auto actual = friendOrFoe(input);
    
    • genNumber things also has no business being in the local scope, since they never change between the runs. I would suggest renaming them so they convey what they generate (e.g. genStrLength, genArrLength and etc) and move them to the body of Describe as well.
    • Maybe make it so the number of inputs in the is larger than 20? Should probably make it aligned with the boundaries in other translations.
    • Adding assertion messages to sample test cases wouldn't hurt.
  • Custom User Avatar

    okay I added Asseert messages.Take a look and tell me how I should tweak things. Thanks!

  • Custom User Avatar

    Except for assertion messages which I dont really get it should be fine now. I also dont know how to utilise preloaded. I would welcome any advice you have!

  • Custom User Avatar
  • Custom User Avatar

    I dont really know how to write translation. if you want message me on discord and explain it to me: roiqk

  • Custom User Avatar
  • Custom User Avatar

    Will fix! This is my first ever translation.

  • Custom User Avatar
    • No random tests
    • #include <vector> should be present in every part where it is used
    • Assertion messages?
  • Custom User Avatar

    Probably it is best if you stay away from tall building for a while. Getting into a lift might trigger a relapse.

  • Custom User Avatar

    Nice solution. After I finished this kata in twice the lines I studied your code and rewritten it. Good job!

  • Custom User Avatar

    Took me days... and my wellbeing. I finished... but at what cost?

  • Custom User Avatar
  • Custom User Avatar

    When I run my C++ solution I get this: Exit Code: 132
    Can someone explain what it means and how to fix it?

  • Loading more items...