Handling optionality of test cases that require additions to the description.md #1749
Replies: 2 comments 7 replies
-
Potential solutionThis is the first potential solution that came to my mind. I don’t like it too much. Introduce a new optional key to {
"uuid": "bd1eab16-7603-4a77-ae4e-23c930fe39cd",
"description": "Ordering",
"description_inserts": [
"Ordering of rational numbers: `a/b < c/d` if and only if `a * sign(b) * |d| < |b| * c * sign(d)`.\n",
" - the ordering of rational numbers."
],
"property": "<",
"comments": ["..."]
}
diff --git a/exercises/rational-numbers/description.md b/exercises/rational-numbers/description.md
index 55ebaeb4b..39f9ed475 100644
--- a/exercises/rational-numbers/description.md
+++ b/exercises/rational-numbers/description.md
@@ -18,9 +18,12 @@ Exponentiation of a rational number `r = a/b` to a real (floating-point) number
Exponentiation of a real number `x` to a rational number `r = a/b` is `x^(a/b) = root(x^a, b)`, where `root(p, q)` is the `q`th root of `p`.
+<!-- bd1eab16-7603-4a77-ae4e-23c930fe39cd -->
Implement the following operations:
- addition, subtraction, multiplication and division of two rational numbers,
- absolute value, exponentiation of a given rational number to an integer power, exponentiation of a given rational number to a real (floating-point) power, exponentiation of a real number to a rational number.
+<!-- bd1eab16-7603-4a77-ae4e-23c930fe39cd -->
Your implementation of rational numbers should always be reduced to lowest terms. For example, `4/4` should reduce to `1/1`, `30/60` should reduce to `1/2`, `12/8` should reduce to `3/2`, etc. To reduce a rational number `r = a/b`, divide `a` and `b` by the greatest common divisor (gcd) of `a` and `b`. So, for example, `gcd(12, 8) = 4`, so `r = 12/8` can be reduced to `(12/4)/(8/4) = 3/2`. We’d likely have to introduce UUIDs and {
"description": "Addition",
"uuid": "de6b3f52-a3ea-4761-ae6a-d1e9b48c85ea",
"description_inserts": [
"The sum of two rational numbers `r₁ = a₁/b₁` and `r₂ = a₂/b₂` is `r₁ + r₂ = a₁/b₁ + a₂/b₂ = (a₁ * b₂ + a₂ * b₁) / (b₁ * b₂)`."
],
"cases": ["..."]
} Downsides
Granted, this is an extreme example because most exercises are not made up of cleanly separated properties. |
Beta Was this translation helpful? Give feedback.
-
I think the above mentioned solution is not ideal, as it mixes responsibilities a bit too much I feel (canonical data now contains exercise description text). |
Beta Was this translation helpful? Give feedback.
-
Problem
In #1674 the notion that every test case is optional was introduced. However, some optional test cases may require additions to the
description.md
file. There may also be situations where one will choose between two contradicting test cases of which both require different instructions.Tracks could add these descriptions in the track-specific README inserts but these explanations are likely not track-specific and would benefit from being synced across repos.
Example
#1736 introduces a new test case for the
rational-numbers
exercise that introduces tests for the ordering of rational numbers. The ordering relation is not trivial and needs to be explained to students who are not familiar with rational numbers:Tracks that choose to not implement this test would be left behind with an irrelevant stub in the description.
Beta Was this translation helpful? Give feedback.
All reactions