Created
November 10, 2019 09:03
-
-
Save uzilan/2b807a852b802683bca48ad5a387a113 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uzilan Oct 2nd at 11:21 PM | |
Hamming 2.3.0 allows both strands to be empty, but if only the left or the right strands are empty then an exception should be thrown with different error messages for each case. This means one should check for many different situation. And this is only the third exercise. Isn’t it a bit of an overkill? | |
12 replies | |
uzilan 1 month ago | |
https://raw.githubusercontent.com/exercism/problem-specifications/master/exercises/hamming/canonical-data.json | |
uzilan 1 month ago | |
Specifically, for Kotlin, that means you can’t use the idiomatic require because the condition (not empty) is only required if only one strand is empty | |
SleeplessByte:flag-nl: 1 month ago | |
In many tracks it might be a later exercise. I also don't like the weird requirements myself. Personally, I'd probably drop the empty strands test case. IMO it doesn't make sense in the first place | |
SleeplessByte:flag-nl: 1 month ago | |
(we only recently added optional key to the canonical data and these would make a good candidate perhaps) | |
Simon Shine:haskell: 1 month ago | |
@uzilan those test cases were propagated from the Haskell track after I encouraged this. When @Glenn Jackman ported the exercise to Tcl, I realized that the wording of the error implied unique errors. We went with just one error message and propose that it gets changed in problem-specifications. It was an oversight on my behalf when reviewing the PR. | |
Simon Shine:haskell: 1 month ago | |
@SleeplessByte they mainly make sense in languages that use pattern matching: https://github.com/exercism/haskell/pull/796 | |
tqa236tqa236 | |
#796 Hamming: Add a test case to avoid wrong recursion solution | |
This solution will pass all the current test cases but fail on the new one: | |
module Hamming (distance) where | |
distance :: String -> String -> Maybe Int | |
distance [] [] = Just 0 | |
Show more | |
Comments | |
4 | |
<https://github.com/exercism/haskell|exercism/haskell>exercism/haskell | Jan 30th | Added by GitHub | |
Simon Shine:haskell: 1 month ago | |
Having taught FP for a number of years, I can say that this kind of bug in student solutions is not at all uncommon. Since there are other tracks where pattern matching on lists occurs, it made sense to share it. Also, if you think about it, it's a much simpler case than some of the previous ones, which makes it a better representative of an equivalence class of negative input. (edited) | |
uzilan 1 month ago | |
Kotlin has pattern matching as well, but I think in this early stage it is more important to teach mentees about require, which I often tell them about when mentoring this exercise. | |
NobbZ 1 month ago | |
The real precondition is not that both have to be filled or empty, but that both have to be of the same length! Also Hamming makes totally sense for the empty lists. Even though this problem states it as a biological problem, hamming distance is used in the IT as well to determine difference of any sequence. | |
Simon Shine:haskell: 1 month ago | |
The related problem of finding the edit distance of strings of possibly different lengths has another complexity. | |
SleeplessByte:flag-nl: 1 month ago | |
levehnsteinnnn | |
SleeplessByte:flag-nl: 1 month ago | |
The canonical data kinda leads implementation. If the error for "empty" wasn't a thing, and there was just an error "lengths are not equal", it would still be able to have all the test cases, but implementation would be much easier? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment