Authoring Python Content: "The reference solution or data must not be defined in the Preloaded code. The reference solution must not be defined in the top-level scope of the test suite."
Please copy verify from Preloaded code into the test_random() function. test_example() can be removed from Test Cases. It is fine to keep the existing Preloaded code for running Sample Tests.
Well, you were using preloaded function scrambled, which internally uses unicodedata. Without proper understanding of what that does, it's kind of hard to imagine what you yourself should do. But this kata is very strange either way...
It (unicodedata) is not actually required to pass the kata (though it probably makes it easier)
I've featured this kata in a "Daily Beta" thing we have going on in the Codewars Discord, and a few people found the description confusing, in knowing what was actually being asked of them (ie. the actual task).
Maybe it could be slightly reworked, to more clearly state the actual task? I don't think this is a big problem (hence the 'suggestion' tag), but I thought I would at least mention it.
I have renamed 2 of the categories to match them with algebraic groups as with the other categories. The change to the test code is backwards compatible. If you see 'N' or 'M' in solutions, these map to 'C1' and 'D1'.
This comment is hidden because it contains spoiler information about the solution
You have the fastest solution this far, and still not satisfied? O_o :p
So apparently View Solution clears any reply being written. That's fun.
I had a difficult time getting my solution to pass consistently. To do so, the test cases have to scramble the input several times and then choose the "most random". This does make some sense, actually, but there's a confession buried in there. Which input is scrambled best depends on how you measure, and it's no coincidence that my heuristic matches the testing code exactly, which feels an aweful lot like cheating. I had thought my approach was very plain and others would be able to beat the kata by checking more clever conditions, but computationlan also reports that his solution only passes half the time, much like yours. His approach is slightly different, but I think it's exactly the right kind of solution, and I would in fact like to see it pass consistently.
So I'm very open to changing the test cases to, first of all, select the more random input based on a broader heuristic, and then to build in some leniency. I was actually thinking something along the lines you spelled out, except the tests don't have to pass or fail immediately after the requisite batch. They can be in a grey area and keep testing just to make sure they don't fail. This should help discriminate some of the edge cases more cleanly. A solution that usually fails might reach the grey area by chance, but it's not likely to stay there. A solution that usually passes might fall into the grey area on accident, but it's not likely to fail.
As to languages, I don't feel there's much point to randomizing their order since the script is immediatly apparent from the input string anyway. However, if there were several languages using the same script, probably just the Latin/Roman we're most familiar with, then I agree this could be a better test. You're not going to get the same stop words or other such hacks in English as in German, Gaelic, Turkish, Tagalog, Africaans, Swahili, or any of the romance languages.
I am curious, are other solutions passing 100% of the time? I got mine to pass on average 98% of the tests (which was close enough to pass all after submitting a couple times), but that certainly wont survive any updates to the kata. Based on the nature of the kata I find it very difficult to imagine a solution that is guaranteed to pass 100% of the time.
Edit: An idea to potentially handle some of the randomness:
Of course, just an idea and perhaps your solution can already pass 100%. If you do want highly reliable solutions though I would suggest increasing the number of tests to prevent solutions like mine and computationlan's from passing.
@Unnamed, could you contribute to this discussion, please? https://www.codewars.com/kata/5e95a43ee32f8a00183a95ab/discuss/python#603a1ed61cdbb900128bf588
Excuse me for off-topic, please :D
Fixed by altering one of the examples.
Interesting. The kata was originally written with precise calculations in mind, but I wonder if it would make more sense to just avoid testing cases like this.