-
-
Notifications
You must be signed in to change notification settings - Fork 546
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
luhn: It's about checksums. #523
Comments
I find it quite helpful to have to parse and filter input, it makes the exercise seem more like actually writing a function that might actually be used rather than just implementing an algorithm. (At least for me) the idea is to practice writing realistic code in different languages to get a feel for them, so I appreciate extra touches such as handling dodgy input. |
I think there are enough practice problems that require parsing and filtering input. I agree with @Insti that the focus should be on calculating the checksum. |
There's a definite tension here: parsing is well-covered by Exercism, but skipping it in any individual exercise is certainly likely to reduce the "real-world applicability." I'd be in favor of trimming down to assume valid input, and continuing to test validity (vs. returning the actual checksum value; not sure if that was part of the original suggestion here or not, so figured I'd clarify). |
Having been through the exercises for Rust, and then spending some time making the luhn tests fit the description in the README, I found this specific test had quite an interesting filtering section. The solution should only allow digits or The actual algorithm implementation by comparison was quite mundane. I haven't written a lot of exercises, so I don't have much perspective on that, just giving my feeling as someone going through all the tests to practice a language.
I don't think anyone suggested removing the |
In the current form, this exercises forces us to return
If the exercise is changed as proposed, given the above options, I would either:
Either way, I would end up checking any input string. It is hard to avoid checking the input data when the input format allows invalid data... This one is hard, @Insti ...I'm divided... I would say that I support the change 👍 , not because it saves the work of checking the input, but because is would remove the tests that force signaling invalid input as a |
Makes sense to me (it'd be |
Could we clarify how non-space whitespace is handled? The description says they are disallowed but none of the tests check for that. I see many solutions that use the convenient |
Run non-exercise tests in CI Disable code coverage reporting when we're running in CI
There's a little footnote here. Because the algorithm involves doubling every other digit, you have to keep track of how many digits you've seen, not just where you are in the string. (Or sanitise the string beforehand.) Test cases containing whitespace are important for catching the mistake where you double the digit either side of a space, for example. |
On the other hand, there was a decision a while back, the reference to
which I am currently too lazy to dig up, that most exercises should _not_
test input cleaning; students should be able to assume that their inputs
will be generally valid for the problems given. Input cleaning should be
required only when it's directly relevant to the point of the exercise;
otherwise, it would be required for every single exercise.
There are exercises for which exceptions should be made, but in my opinion
Luhn isn't one of them.
…On Wed, Nov 28, 2018 at 7:56 PM John Arundel ***@***.***> wrote:
There's a little footnote here. Because the algorithm involves doubling
every *other* digit, you have to keep track of how many *digits* you've
seen, not just where you are in the string. (Or sanitise the string
beforehand.)
Test cases containing whitespace are important for catching the mistake
where you double the digit either side of a space, for example.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#523 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHdeTsPCDZ0cYtkrXOv745YNDbq2ZItPks5uztxrgaJpZM4LxMND>
.
|
The main purpose of this problem is doing the checksum calculation so checking that the input string is valid should not be part of the requirements.
Test strings in the canonical-data.json file should all be well formed and only contain numbers. (Although I could be convinced that adding spaces for readability is a good idea.)
The text was updated successfully, but these errors were encountered: