Ad
  • Custom User Avatar

    C++ Translation. Based heavily on the current Python translation since it's the one that has random tests.

  • Custom User Avatar

    Your solution is easily viewable by clicking "View Solution" under your comment, so there is no need to share it in discourse. But if you really want to, be sure to click the spoiler checkbox before posting ^^

  • Custom User Avatar

    You must sort it alphabetically (case-sensitive, and based on the ASCII values of the chars) and then return the first value.

    Abt the Description: Sorting should not be encouraged as the only way to do this (so "must" is too strong here) and the use of "return" here is confusing because you shouldn't be returning the first value as-is

  • Custom User Avatar
  • Custom User Avatar

    Good place to end this discussion. Not a good look on the homepage

  • Custom User Avatar
  • Custom User Avatar

    Approved by someone (can you resolve the suggestion?)

  • Custom User Avatar

    This one LGTM! Tried to approve but apparently if the author is active you have to wait a week to approve. If nobody raises any further issues in the discourse (incl. the author themself), I'll approve it in a week's time

  • Custom User Avatar
  • Custom User Avatar

    The Kata is enjoyable, but the first part of the description has run-on sentences that make it hard to read. Consider changing it to something like:

    You are given a string where each letter is followed by a number.

    The number is an index that indicates where that letter should be placed in the final string.

    If a letter has no number after it (i.e., it’s directly followed by another letter), it goes at the end of the final string.

    Also, place ## to the left of both Description and Task in the description markdown (i.e., ## Task and ## Description).
    This is with regards to the description. The tests themselves are very underbaked and you should've at least added random tests before publishing because this might reflect on the Kata rating (it shouldn't but it does)

  • Custom User Avatar

    Please give these guidelines a read. Particularly, try to look at this example as a good idea of how the tests should be formatted: try to avoid using preloaded, as the guidelines state, and instead of std::cout, supply an ExtraMessage argument to Assert::That. Also the if (r > INT_MAX) branch seems redundant to me since the maximum value generated by your tests, (INT_MAX / 1024) + 200000 * 1000 is still less than INT_MAX. Make sure every code snippet begins with any and all headers used in that snippet

  • Custom User Avatar

    All is good now! I just realized I goofed up when I told you to put no_of_staff outside. It's meant to be different each time, right? Just put it back in and I'll approve. Sorry, it's totally my bad

  • Custom User Avatar

    Looks very good and almost ready to approve. Just correct < 80 in your reference solution and submission solution to <= 80 and take the engines, distributions, places, base, no_of_staff out of the get_random_staff function and instead just paste them directly above the function. Recreating them within every call is unnecessary and suboptimal. This might mean you may have to use braces instead of parentheses (so C++ doesn't parse them as function declarations). Also, move the using type alias into the private section too, so your type aliases are invisible to the user. Other than this, I have no comments. Looks good! Just rearrange your code into:

    private:
          using Staff = std::map<std::string, std::string>;
          std::string ref_sol(const Staff &staff){
              // ...
          }
          // Note the angular brackets for initialization instead of round parentheses.
          std::mt19937 gen{std::random_device{}}; // standard mersenne_twister_engine seeded with random device
          std::uniform_int_distribution<std::size_t> dis{0, 25}; // emp_name_chars
          // Other distributions, same as above...
          std::array<std::string, 10> places = {"accounts","finance","canteen","regulation","trading","change","IS","retail","cleaning","pissing about"};
          std::string base = "abcdefghijklmnopqrstuvwxyz";
          int no_of_staff = dis3(gen);
    
          Staff get_random_staff() {
              // ...
          }
    };
    

    In the fixed tests, just define the type alias inside the It. Try to reduce the scope of your aliases as much as possible.

  • Custom User Avatar

    I don't see any of the changes. Are you sure you've clicked publish? Also about where to put functions, Describe is just a macro and it's a struct behind the scenes. You can have a private section within it. It's also a good place to put your reference solution too (more info here). Just do this:

    Describe(whatever)
    {
        // It(blah_blah) {....}
        // Other It blocks...
    private:
        // Functions and other 'secret' variables can go here.
        // If you want, you can put the engine and distributions here too.
        std::map<std::string, std::string> gen_random_test()
        {
            // return ...
        }
    };
    
  • Custom User Avatar

    Good job! I have a few suggestions:

    • You correctly use std::size_t for the distributions, but no_of_staff and q and l (the nested loop variables) should also be std::size_t. Intermixing integer types causes the tests to generate a warning in the log.
    • Try not to mix different naming conventions. The names boredom and Myboredom are inconsistent with each other style-wise. Same with BAS, no_of_staff, etc. You seem to lean most towards snake case, so maybe turn most things into snake case.
    • Try to refactor some things into functions for ease of readability. For example, as so:
    for (int x = 0; x < NO_OF_TESTS; x++) {
        auto rand_staff = get_random_staff();
        auto expected   = ref_sol(random_staff);
        Assert::That(boredom(random_staff), Equals(expected));
    }
    
    • Add feedback messages for when the user fails a test. Now, this would be cumbersome manually. Just #include <fmt/ranges.h> and use the below template for your assertions. This might mean you have to store the std::maps in the fixed tests into variables so you can reference them to generate feedback messages:
    Assert::That(boredom(/* name of staff variable */), Equals(/* expected */), ExtraMessage(fmt::format("Incorrect output for staff = {}:\n", /* name of staff variable */)));
    
  • Loading more items...