resistor-color-trio: Add exercise (with extensions)#869
resistor-color-trio: Add exercise (with extensions)#869sshine merged 9 commits intoexercism:masterfrom sshine:resistor-color-trio
Conversation
This adds the exercise from exercism/problem-specifications#1551. In addition to the canonical exercise, this implementation extends: - Add a "zero" test case (Black, Black, Black). - Add a `Data.Text` hint in `.meta/hints.md`. - Export both a `label` function *and* an `ohms` function: While the exercise is mainly about printing a formatted string, this nudges the student towards separating print and calculate. - For totality, since `Resistor` allows expressing resistors in the megaohm and gigaohm ranges, extend the exercise so that the correct unit beyond kiloohms are returned. - Extended unit tests are added, and coverage is described as such: Canonical tests are marked with 'x'. Extended tests are marked with 'y'. Optional (commented out) tests are marked with 'z'. ``` Black xyyyyy xyy Brown xyz x Red xyz xz Orange xxz x Yellow xyz x Green xyz yz Blue xyz y Violet xy y Grey xy yz White yy y ``` The over-representation of Black is partly caused by the fact that canonical and extended tests avoid edge cases like "4.7 kiloohms". There is some didactial point in incremental improvements, and as such, canonical and extended tests partially validates solutions. Optional (commented out) tests make the exercise considerably more difficult, so they are accompanied with a disclaimer that students may choose freely to include them or not. This way, students who are oblivious to the edge cases will not be aware of them, and students who are not (either by thinking or by inspecting the unit tests) will be able to choose.
|
This PR is currently marked as WIP because the example solutions don't handle the optional tests. |
|
Currently no special-cases for I'm unsure if they should be added as additional optional tests, or simply not be mentioned at all. |
|
Also, I learned something very cool: |
Make it a non-core exercise unlocked after resistor-color-duo, which is also a non-core exercise. Both are unlocked by pangram.
This should make maintenance easier. Although the linebreaks seem arbitrary to the student, they are not particularly invasive.
|
I've realized that the derived let ten1 = Resistor (Brown, Black, Black)
ten2 = Resistor (Black, Brown, Brown)
ohms ten1 == ohms ten2 -- True
ten1 == ten2 -- FalseFortunately, since we only test I have an idea for making a subsequent refactoring exercise where this insufficiency could come handy. |
|
I've not enabled the optional tests, so CI does not reveal that the example solutions work for them. The following demonstrates that this is the case success-standardsuccess-textThe exact same. |
resistor-color-duo was added in #808. resistor-color-trio was added in #869. Yet there is no resistor-color. I argue that there shouldn't be. A reasonable solution might look like ```haskell data Color = ... deriving (Eq, Enum, Bounded) colorCode :: Color -> Int colorCode = fromEnum colors :: [Color] colors = [minBound..] ``` which makes it approximately as simple as the gigasecond exercise which was marked as deprecated in #280 (decision made in #230). Still, if it is simply missing, it will appear as an exercise that is potentially implementable on https://tracks.exercism.io/haskell/master/unimplemented Since a question was raised about this exercise once, marking it as foregone will limit further requests made in vain.
This adds the exercise from exercism/problem-specifications#1551.
In addition to the canonical exercise, this implementation extends:
Add a "zero" test case (Black, Black, Black).
Add a
Data.Texthint in.meta/hints.md.Export both a
labelfunction and anohmsfunction: While theexercise is mainly about printing a formatted string, this nudges
the student towards separating print and calculate.
For totality, since
Resistorallows expressing resistors in themegaohm and gigaohm ranges, extend the exercise so that the correct
unit beyond kiloohms are returned.
Extended unit tests are added, and coverage is described as such:
Canonical tests are marked with 'x'.
Extended tests are marked with 'y'.
Optional (commented out) tests are marked with 'z'.
The over-representation of Black is partly caused by the fact that
canonical and extended tests avoid edge cases like "4.7 kiloohms".
There is some didactial point in incremental improvements, and as
such, canonical and extended tests partially validates solutions.
Optional (commented out) tests make the exercise considerably more
difficult, so they are accompanied with a disclaimer that students
may choose freely to include them or not.
This way, students who are oblivious to the edge cases will not be
aware of them, and students who are not (either by thinking or by
inspecting the unit tests) will be able to choose.