I was creating the Anagram test for a new track (Odin) and realized that one of the test is flawed.
The Test in question is:
{
"uuid": "a6854f66-eec1-4afd-a137-62ef2870c051",
"description": "handles case of greek letters",
"scenarios": ["unicode"],
"property": "findAnagrams",
"input": {
"subject": "ΑΒΓ",
"candidates": ["ΒΓΑ", "ΒΓΔ", "γβα", "αβγ"]
},
"expected": ["ΒΓΑ", "γβα"]
},
This test is the only one using Unicode, with, I suspect, the goal to prevent people just converting the word and candidate strings to bytes, sorting them and then comparing. It looks like the test is designed to force them to process the string as unicode characters.
But I did just that (convert to a bunch of bytes and sort the two strings before comparing) and, to my surprise, the test passed.
The problem is that all 6 letters used in that case “ΒΓΔγβα” have the same upper byte (0x03) so when I break (accidentally) the unicode characters into their separate bytes and sort them, I end up with the same six top bytes followed by the 6 lower bytes and the comparison passes.
To make the test fail when the student forget to deal with unicode, we should have at least one of the six letter have a different upper byte (we may have to mix greek and chinese for example).
Note: the next exercise, compare “a⬂”, “€a” which have the same bytes and therefore require the student to deal with unicode for the test not to fail. So this is really not a big deal as they can’t pass all the tests without dealing with unicode.