Ad
  • Custom User Avatar

    Hey, absolutely happy how the kata turned out, that it got a JS translation and that people like it. Thanks for all the updates and help!

  • Custom User Avatar

    Ok, ok, makes sense. I'm not that active here and don't know all the minutiae, so I'll trust your judgement. Plus, would give me a reason to get back to this problem myself and try to find a better solution. :)

  • Custom User Avatar

    I'd prefer to keep it at a lower difficulty level and see a wider range of solutions. I think the n-queens problem is interesting, because quite a lot of different algorithms are possible. But not many would be able to solve >100 in a reasonable time. So please keep it at 100.
    You could always add a second 1-kyu version to get high perfomance solutions.

    @Blind4Basics: let's disagree. :) I prefer it at lower difficulty and more approachable. Don't really see the point of making this even harder and have nobody even try it.

  • Custom User Avatar

    Congrats to the great solution and thanks for the input.

    I think the Kata is challenging as it is. In 2 years it has only 6 solutions.
    Go ahead and adapt the kata and testcases, but I would prefer to keep the max n reasonably low. It should exclude brute force solutions, but allow reasonable solutions even if they are not highly optimized like yours. 50 should be more than plenty to exclude brute forcing, but I'd be fine with 100 to adjust for the new compiler version.

    In addition you could add a 1 Kyu "high perfomance" version of the Kata with higher max n.

  • Custom User Avatar

    Congratulations on solving the Kata and thanks for the input! I chose the maximum board size to exclude pure brute force solutions, so yes, some good thinking or research is needed.
    I really like the submitted solutions so far. Very different approaches and ideas how to optimise the strategy.

    Regarding the namespace requirement, I'm not 100% sure why I chose to use a namespace back then, probably to avoid problems with the tests. (I could't find documentation on the test framework.) I'll leave it in now to keep the previous solutions working, but added the namespace to the example in the description. It is also in the initial solution and the tests.

  • Custom User Avatar

    Connect your account to your GitHub profile. Then change the pic on the GitHub profile, it will be used here as well.

  • Custom User Avatar

    As long as there are values that are > INT MIN, it works.
    Note that the values are compared to currentHigh, which is initially set to INT MIN. The comparison with 0 is with the position in the vector.

  • Custom User Avatar

    There are some redundancies in this solution, I added a refactored version.

  • Custom User Avatar

    In C++ the sample test is not implemented.

  • Custom User Avatar

    "delete &" is not what you want, the & makes no sense there.
    The memcpy code is also wrong. You are only copying 1000 bytes, not 1000 ints.
    Much simpler:

    It(should_work_for_random_tests_n_1000_An_10000) {
            srand((unsigned)time(NULL));
            cout << "<p><font color=\"blue\">n == 1000, a[n] <= 10000</font></p>" << endl;
            int count = 3;
            while (count--) {
                std::array<int, 1000> array;
                for (auto i = 0; i < 1000; ++i)
                    array[i] = rand() % 10000;
                Assert::That(don't see this!);
            }
        }
    

    And should you need a copy you can then simply:

    std::array<int, 1000> array2 = array;
    
  • Custom User Avatar

    This is a tough kata. :) I only managed a brute force algorithm so far and it times out for the larger N. N = 100000 is totally out of reach. I need a much better algorithm, would have to be linear probably.

    May I suggest a "low performance" version of this Kata at a lower difficulty with smaller N, so simpler algorithms have a chance?

  • Custom User Avatar

    The tests of the C++ version have a bug. In line 10 of the sample tests, there is a superfluous "N" in "a1[N]". After deleting it (a1[]), the tests compile fine.

    I assume the same bug is in the full tests, as they throw the same compliation error.

  • Default User Avatar

    Yes, pretty sure the bias test is correct and actually rather lenient.

    Try testing your generated passwords yourself. Generate 10000 passwords, count the number of occurences of each allowed character. Check if there are any outliers, that are not produced at a similar rate as the others. For example: if there are 250 occurences of 'a', but only 100 of '1', the code is biased.

  • Default User Avatar

    Yes, this was not a good Kata for me either. All of the description is completely misleading. There is no real mathematical or physics formula that works as a solution to the described process of drying potatoes. You simply have to find an arbitrary formula that relates the testcases to their results, completely disregarding all of the description. Not fun and not instructive.

  • Default User Avatar

    The test looks correct to me. It tests the frequency of use of each allowed character. In 10000 generated passwords, each allowed character should be used equally often. As there is some randomness, the test allows for a deviation of 50% for each character's frequency from the mean.

    In short: you need to make sure that all characters are used with the same probability / frequency.

  • Loading more items...