-
-
Notifications
You must be signed in to change notification settings - Fork 402
simple cipher ignore spaces etc #851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @Alexander-Taran, thank you for reporting the issue!
The idea for the Exercise is that you shouldn't need to concern yourself with any kind of input validation or handling incorrect input. It's out of scope for this exercise. The test case There have been multiple attempts to add input validation to this exercise to problem specifications but they all seem to have been rejected, e.g. exercism/problem-specifications#1298 Problem specifications is the repository where all Exercism tracks share data about exercises. Since this test case is not related to Elixir's internals as a programming language, my desired approach to this problem would be to just remove it so that we don't even lead people thinking about invalid input, as per the organization-wide goal of the exercise. @jiegillet @neenjaw what do you think? |
@angelikatyborska I see. consider this inputs for encode function: encode("aaaa","a") == "aaaa"
encode("aaaa","ab") == "abab"
encode("aa aa","a") == "aa aa"
encode("aa aa","ab") == "ab ba" or encode("aa aa","ab") == "ab ab" ? It is not clear from anywhere in the exercise how not encoding spaces should be treated. |
Another way is to add a test: # This one exists already
@tag :pending
test "only lowercase a-z are translated, rest are passed through" do
assert SimpleCipher.encode("this is a test!", "d") == "wklv lv d whvw!"
assert SimpleCipher.decode("wklv lv d whvw!", "d") == "this is a test!"
end
@tag :pending
test "passed through letters consume key letters" do
assert SimpleCipher.encode("this is a test!", "abc") == "tiks ks c ugsu!"
assert SimpleCipher.decode("tiks ks c ugsu!", "abc") == "this is a test!"
end I personally think this is a bit more satisfying for people who like to think outside the box and about real world application, as some programmers tend to do. Happy to do a quick PR. |
I know, I understood the problem. My point about not validating input is that it doesn't matter how encoding spaces should be treated because spaces are not valid input. We shouldn't even be testing invalid input in this exercise. However, I am happy to accept Jie's proposal that spaces do consume a part of the key if that will be more satisfying to people. But if I ever get somebody complaining about the exercise that they believe it should be the opposite, I will remove both tests 😂. |
Agreed 🤝 |
@angelikatyborska remove both. (-: |
🤣 I didn't think the complain would come so quickly 🤣 I must abide to my agreement then, let's remove both tests! I'll update my PR. |
@Alexander-Taran Done! When v3 launches on the first of September, this exercise will be up-to-date without the test for spaces. |
"only lowercase a-z are translated, rest are passed through"
And I've seen couple of solutions that simply emit non-letters and move on with key advanced as well.
The key for the test is "a" so the tests pass.
But it is unclear what was the original idea.
To advance the key but not encode non-letters or consume the key only while encoding.
How would the test look with a lengthier key?
The text was updated successfully, but these errors were encountered: