diff --git a/exercises/practice/armstrong-numbers/.docs/instructions.md b/exercises/practice/armstrong-numbers/.docs/instructions.md index 452a996..5e56bbe 100644 --- a/exercises/practice/armstrong-numbers/.docs/instructions.md +++ b/exercises/practice/armstrong-numbers/.docs/instructions.md @@ -1,12 +1,14 @@ # Instructions -An [Armstrong number](https://en.wikipedia.org/wiki/Narcissistic_number) is a number that is the sum of its own digits each raised to the power of the number of digits. +An [Armstrong number][armstrong-number] is a number that is the sum of its own digits each raised to the power of the number of digits. For example: - 9 is an Armstrong number, because `9 = 9^1 = 9` -- 10 is *not* an Armstrong number, because `10 != 1^2 + 0^2 = 1` +- 10 is _not_ an Armstrong number, because `10 != 1^2 + 0^2 = 1` - 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153` -- 154 is *not* an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190` +- 154 is _not_ an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190` Write some code to determine whether a number is an Armstrong number. + +[armstrong-number]: https://en.wikipedia.org/wiki/Narcissistic_number diff --git a/exercises/practice/armstrong-numbers/.meta/tests.toml b/exercises/practice/armstrong-numbers/.meta/tests.toml index 9cb0475..fdae1a5 100644 --- a/exercises/practice/armstrong-numbers/.meta/tests.toml +++ b/exercises/practice/armstrong-numbers/.meta/tests.toml @@ -35,3 +35,11 @@ description = "Seven-digit number that is an Armstrong number" [7ee45d52-5d35-4fbd-b6f1-5c8cd8a67f18] description = "Seven-digit number that is not an Armstrong number" + +[5ee2fdf8-334e-4a46-bb8d-e5c19c02c148] +description = "Armstrong number containing seven zeroes" +comment = "Upper bound of Nat type is 18446744073709551615" + +[12ffbf10-307a-434e-b4ad-c925680e1dd4] +description = "The largest and last Armstrong number" +comment = "Upper bound of Nat type is 18446744073709551615" diff --git a/exercises/practice/bob/.meta/testAnnotation.json b/exercises/practice/bob/.meta/testAnnotation.json index 070b3da..4f1dbbd 100644 --- a/exercises/practice/bob/.meta/testAnnotation.json +++ b/exercises/practice/bob/.meta/testAnnotation.json @@ -81,7 +81,7 @@ }, { "name": "Multiple line question", - "test_code": "verify do\n labeled \"Multiple line question\" do\n expected = \"Whatever.\"\n actual = response \"\\nDoes this cryogenic chamber make me look fat?\\nNo.\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" + "test_code": "verify do\n labeled \"Multiple line question\" do\n expected = \"Sure.\"\n actual = response \"\\nDoes this cryogenic chamber make\\n me look fat?\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { "name": "Starting with whitespace", diff --git a/exercises/practice/bob/.meta/tests.toml b/exercises/practice/bob/.meta/tests.toml index ea47d6b..5299e28 100644 --- a/exercises/practice/bob/.meta/tests.toml +++ b/exercises/practice/bob/.meta/tests.toml @@ -71,6 +71,7 @@ description = "alternate silence" [66953780-165b-4e7e-8ce3-4bcb80b6385a] description = "multiple line question" +include = false [5371ef75-d9ea-4103-bcfa-2da973ddec1b] description = "starting with whitespace" @@ -83,3 +84,7 @@ description = "other whitespace" [12983553-8601-46a8-92fa-fcaa3bc4a2a0] description = "non-question ending with whitespace" + +[2c7278ac-f955-4eb4-bf8f-e33eb4116a15] +description = "multiple line question" +reimplements = "66953780-165b-4e7e-8ce3-4bcb80b6385a" diff --git a/exercises/practice/bob/bob.test.u b/exercises/practice/bob/bob.test.u index 477a1b2..7c81e24 100644 --- a/exercises/practice/bob/bob.test.u +++ b/exercises/practice/bob/bob.test.u @@ -160,8 +160,8 @@ bob.test.ex20 = verify do bob.test.ex21 = verify do labeled "Multiple line question" do - expected = "Whatever." - actual = response "\nDoes this cryogenic chamber make me look fat?\nNo." + expected = "Sure." + actual = response "\nDoes this cryogenic chamber make\n me look fat?" label "expected" expected label "actual" actual ensureEqual expected actual diff --git a/exercises/practice/change/.docs/instructions.md b/exercises/practice/change/.docs/instructions.md index d6ea63b..5887f4c 100644 --- a/exercises/practice/change/.docs/instructions.md +++ b/exercises/practice/change/.docs/instructions.md @@ -1,16 +1,8 @@ # Instructions -Correctly determine the fewest number of coins to be given to a customer such -that the sum of the coins' value would equal the correct amount of change. +Determine the fewest number of coins to give a customer so that the sum of their values equals the correct amount of change. -## For example +## Examples -- An input of 15 with [1, 5, 10, 25, 100] should return one nickel (5) - and one dime (10) or [5, 10] -- An input of 40 with [1, 5, 10, 25, 100] should return one nickel (5) - and one dime (10) and one quarter (25) or [5, 10, 25] - -## Edge cases - -- Does your algorithm work for any given set of coins? -- Can you ask for a change value smaller than the smallest coin value? +- An amount of 15 with available coin values [1, 5, 10, 25, 100] should return one coin of value 5 and one coin of value 10, or [5, 10]. +- An amount of 40 with available coin values [1, 5, 10, 25, 100] should return one coin of value 5, one coin of value 10, and one coin of value 25, or [5, 10, 25]. diff --git a/exercises/practice/change/.docs/introduction.md b/exercises/practice/change/.docs/introduction.md new file mode 100644 index 0000000..b4f8308 --- /dev/null +++ b/exercises/practice/change/.docs/introduction.md @@ -0,0 +1,26 @@ +# Introduction + +In the mystical village of Coinholt, you stand behind the counter of your bakery, arranging a fresh batch of pastries. +The door creaks open, and in walks Denara, a skilled merchant with a keen eye for quality goods. +After a quick meal, she slides a shimmering coin across the counter, representing a value of 100 units. + +You smile, taking the coin, and glance at the total cost of the meal: 88 units. +That means you need to return 12 units in change. + +Denara holds out her hand expectantly. +"Just give me the fewest coins," she says with a smile. +"My pouch is already full, and I don't want to risk losing them on the road." + +You know you have a few options. +"We have Lumis (worth 10 units), Viras (worth 5 units), and Zenth (worth 2 units) available for change." + +You quickly calculate the possibilities in your head: + +- one Lumis (1 × 10 units) + one Zenth (1 × 2 units) = 2 coins total +- two Viras (2 × 5 units) + one Zenth (1 × 2 units) = 3 coins total +- six Zenth (6 × 2 units) = 6 coins total + +"The best choice is two coins: one Lumis and one Zenth," you say, handing her the change. + +Denara smiles, clearly impressed. +"As always, you've got it right." diff --git a/exercises/practice/change/.meta/testAnnotation.json b/exercises/practice/change/.meta/testAnnotation.json index f0a513f..2e85399 100644 --- a/exercises/practice/change/.meta/testAnnotation.json +++ b/exercises/practice/change/.meta/testAnnotation.json @@ -42,5 +42,9 @@ { "name": "error if no combination can add up to target", "test_code": "verify do\n labeled \"error if no combination can add up to target\" do\n expected = None\n actual = findFewestCoins [5,10] 94\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" + }, + { + "name": "a greedy approach is not optimal", + "test_code": "verify do\n labeled \"a greedy approach is not optimal\" do\n expected = Some [10, 10]\n actual = findFewestCoins [1, 10, 11] 20\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } ] diff --git a/exercises/practice/change/.meta/tests.toml b/exercises/practice/change/.meta/tests.toml index 46c2011..7942ae3 100644 --- a/exercises/practice/change/.meta/tests.toml +++ b/exercises/practice/change/.meta/tests.toml @@ -33,6 +33,9 @@ description = "possible change without unit coins available" [9a166411-d35d-4f7f-a007-6724ac266178] description = "another possible change without unit coins available" +[ce0f80d5-51c3-469d-818c-3e69dbd25f75] +description = "a greedy approach is not optimal" + [bbbcc154-e9e9-4209-a4db-dd6d81ec26bb] description = "no coins make 0 change" diff --git a/exercises/practice/change/change.test.u b/exercises/practice/change/change.test.u index f8510d4..e9d4a03 100644 --- a/exercises/practice/change/change.test.u +++ b/exercises/practice/change/change.test.u @@ -86,6 +86,14 @@ change.test.ex11 = verify do label "actual" actual ensureEqual expected actual +change.test.ex12 = verify do + labeled "a greedy approach is not optimal" do + expected = Some [10, 10] + actual = findFewestCoins [1, 10, 11] 20 + label "expected" expected + label "actual" actual + ensureEqual expected actual + test> change.tests = join [ change.test.ex1, change.test.ex2, @@ -97,5 +105,6 @@ test> change.tests = join [ change.test.ex8, change.test.ex9, change.test.ex10, - change.test.ex11 + change.test.ex11, + change.test.ex12 ] diff --git a/exercises/practice/crypto-square/.docs/instructions.md b/exercises/practice/crypto-square/.docs/instructions.md index 8a489f6..6c3826e 100644 --- a/exercises/practice/crypto-square/.docs/instructions.md +++ b/exercises/practice/crypto-square/.docs/instructions.md @@ -4,11 +4,10 @@ Implement the classic method for composing secret messages called a square code. Given an English text, output the encoded version of that text. -First, the input is normalized: the spaces and punctuation are removed -from the English text and the message is down-cased. +First, the input is normalized: the spaces and punctuation are removed from the English text and the message is down-cased. -Then, the normalized characters are broken into rows. These rows can be -regarded as forming a rectangle when printed with intervening newlines. +Then, the normalized characters are broken into rows. +These rows can be regarded as forming a rectangle when printed with intervening newlines. For example, the sentence @@ -22,18 +21,16 @@ is normalized to: "ifmanwasmeanttostayonthegroundgodwouldhavegivenusroots" ``` -The plaintext should be organized in to a rectangle. The size of the -rectangle should be decided by the length of the message. +The plaintext should be organized into a rectangle as square as possible. +The size of the rectangle should be decided by the length of the message. -If `c` is the number of columns and `r` is the number of rows, then for -the rectangle `r` x `c` find the smallest possible integer `c` such that: +If `c` is the number of columns and `r` is the number of rows, then for the rectangle `r` x `c` find the smallest possible integer `c` such that: -- `r * c >= length(message)`, +- `r * c >= length of message`, - and `c >= r`, - and `c - r <= 1`. -Our normalized text is 54 characters long, dictating a rectangle with -`c = 8` and `r = 7`: +Our normalized text is 54 characters long, dictating a rectangle with `c = 8` and `r = 7`: ```text "ifmanwas" @@ -45,8 +42,7 @@ Our normalized text is 54 characters long, dictating a rectangle with "sroots " ``` -The coded message is obtained by reading down the columns going left to -right. +The coded message is obtained by reading down the columns going left to right. The message above is coded as: @@ -54,17 +50,14 @@ The message above is coded as: "imtgdvsfearwermayoogoanouuiontnnlvtwttddesaohghnsseoau" ``` -Output the encoded text in chunks that fill perfect rectangles `(r X c)`, -with `c` chunks of `r` length, separated by spaces. For phrases that are -`n` characters short of the perfect rectangle, pad each of the last `n` -chunks with a single trailing space. +Output the encoded text in chunks that fill perfect rectangles `(r X c)`, with `c` chunks of `r` length, separated by spaces. +For phrases that are `n` characters short of the perfect rectangle, pad each of the last `n` chunks with a single trailing space. ```text "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau " ``` -Notice that were we to stack these, we could visually decode the -ciphertext back in to the original message: +Notice that were we to stack these, we could visually decode the ciphertext back in to the original message: ```text "imtgdvs" diff --git a/exercises/practice/crypto-square/.meta/config.json b/exercises/practice/crypto-square/.meta/config.json index 99b4156..b321e5e 100644 --- a/exercises/practice/crypto-square/.meta/config.json +++ b/exercises/practice/crypto-square/.meta/config.json @@ -15,5 +15,5 @@ }, "blurb": "Implement the classic method for composing secret messages called a square code.", "source": "J Dalbey's Programming Practice problems", - "source_url": "http://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html" + "source_url": "https://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html" } diff --git a/exercises/practice/crypto-square/.meta/testAnnotation.json b/exercises/practice/crypto-square/.meta/testAnnotation.json index 0f4a922..ae3d674 100644 --- a/exercises/practice/crypto-square/.meta/testAnnotation.json +++ b/exercises/practice/crypto-square/.meta/testAnnotation.json @@ -24,7 +24,11 @@ "test_code": "verify do\n labeled \"8 character plaintext results in 3 chunks, the last one with a trailing space\" do\n expected = \"clu hlt io \"\n actual = ciphertext \"Chill out.\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" }, { - "name": "54 character plaintext results in 7 chunks, the last two with trailing spaces", - "test_code": "verify do\n labeled \"54 character plaintext results in 7 chunks, the last two with trailing spaces\" do\n expected = \"imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau \"\n actual = ciphertext \"If man was meant to stay on the ground, god would have given us roots.\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" + "name": "54 character plaintext results in 8 chunks, the last two with trailing spaces", + "test_code": "verify do\n labeled \"54 character plaintext results in 8 chunks, the last two with trailing spaces\" do\n expected = \"imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau \"\n actual = ciphertext \"If man was meant to stay on the ground, god would have given us roots.\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" + }, + { + "name": "normalization results in empty plaintext", + "test_code": "verify do\n labeled \"normalization results in empty plaintext\" do\n expected = \"\"\n actual = ciphertext \"... --- ...\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } ] diff --git a/exercises/practice/crypto-square/.meta/tests.toml b/exercises/practice/crypto-square/.meta/tests.toml index dd83eaf..94ef081 100644 --- a/exercises/practice/crypto-square/.meta/tests.toml +++ b/exercises/practice/crypto-square/.meta/tests.toml @@ -12,6 +12,9 @@ [407c3837-9aa7-4111-ab63-ec54b58e8e9f] description = "empty plaintext results in an empty ciphertext" +[aad04a25-b8bb-4304-888b-581bea8e0040] +description = "normalization results in empty plaintext" + [64131d65-6fd9-4f58-bdd8-4a2370fb481d] description = "Lowercase" @@ -29,3 +32,8 @@ description = "8 character plaintext results in 3 chunks, the last one with a tr [fbcb0c6d-4c39-4a31-83f6-c473baa6af80] description = "54 character plaintext results in 7 chunks, the last two with trailing spaces" +include = false + +[33fd914e-fa44-445b-8f38-ff8fbc9fe6e6] +description = "54 character plaintext results in 8 chunks, the last two with trailing spaces" +reimplements = "fbcb0c6d-4c39-4a31-83f6-c473baa6af80" diff --git a/exercises/practice/crypto-square/crypto.test.u b/exercises/practice/crypto-square/crypto.test.u index 5acd01a..4a042d6 100644 --- a/exercises/practice/crypto-square/crypto.test.u +++ b/exercises/practice/crypto-square/crypto.test.u @@ -47,13 +47,21 @@ cryptoSquare.test.ex6 = verify do ensureEqual expected actual cryptoSquare.test.ex7 = verify do - labeled "54 character plaintext results in 7 chunks, the last two with trailing spaces" do + labeled "54 character plaintext results in 8 chunks, the last two with trailing spaces" do expected = "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau " actual = ciphertext "If man was meant to stay on the ground, god would have given us roots." label "expected" expected label "actual" actual ensureEqual expected actual +cryptoSquare.test.ex8 = verify do + labeled "normalization results in empty plaintext" do + expected = "" + actual = ciphertext "... --- ..." + label "expected" expected + label "actual" actual + ensureEqual expected actual + test> cryptoSquare.tests = join [ cryptoSquare.test.ex1, cryptoSquare.test.ex2, @@ -61,5 +69,6 @@ test> cryptoSquare.tests = join [ cryptoSquare.test.ex4, cryptoSquare.test.ex5, cryptoSquare.test.ex6, - cryptoSquare.test.ex7 + cryptoSquare.test.ex7, + cryptoSquare.test.ex8 ] diff --git a/exercises/practice/hello-world/.docs/instructions.md b/exercises/practice/hello-world/.docs/instructions.md index ed5ce2b..c9570e4 100644 --- a/exercises/practice/hello-world/.docs/instructions.md +++ b/exercises/practice/hello-world/.docs/instructions.md @@ -1,15 +1,16 @@ # Instructions -The classical introductory exercise. Just say "Hello, World!". +The classical introductory exercise. +Just say "Hello, World!". -["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is -the traditional first program for beginning programming in a new language -or environment. +["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment. The objectives are simple: -- Write a function that returns the string "Hello, World!". +- Modify the provided code so that it produces the string "Hello, World!". - Run the test suite and make sure that it succeeds. - Submit your solution and check it at the website. -If everything goes well, you will be ready to fetch your first real exercise. \ No newline at end of file +If everything goes well, you will be ready to fetch your first real exercise. + +[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program diff --git a/exercises/practice/hello-world/.meta/config.json b/exercises/practice/hello-world/.meta/config.json index f88e48c..11c2e30 100644 --- a/exercises/practice/hello-world/.meta/config.json +++ b/exercises/practice/hello-world/.meta/config.json @@ -13,7 +13,7 @@ ".meta/examples/hello.example.u" ] }, - "blurb": "The classical introductory exercise. Just say \"Hello, World!\"", + "blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".", "source": "This is an exercise to introduce users to using Exercism", - "source_url": "http://en.wikipedia.org/wiki/%22Hello,_world!%22_program" + "source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" } diff --git a/exercises/practice/hello-world/.meta/tests.toml b/exercises/practice/hello-world/.meta/tests.toml new file mode 100644 index 0000000..73466d6 --- /dev/null +++ b/exercises/practice/hello-world/.meta/tests.toml @@ -0,0 +1,13 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[af9ffe10-dc13-42d8-a742-e7bdafac449d] +description = "Say Hi!" diff --git a/exercises/practice/knapsack/.docs/instructions.md b/exercises/practice/knapsack/.docs/instructions.md index 3411db9..0ebf791 100644 --- a/exercises/practice/knapsack/.docs/instructions.md +++ b/exercises/practice/knapsack/.docs/instructions.md @@ -1,11 +1,11 @@ # Instructions -Your task is to determine which items to take so that the total value of his selection is maximized, taking into account the knapsack's carrying capacity. +Your task is to determine which items to take so that the total value of her selection is maximized, taking into account the knapsack's carrying capacity. Items will be represented as a list of items. Each item will have a weight and value. All values given will be strictly positive. -Bob can take only one of each item. +Lhakpa can take only one of each item. For example: @@ -21,5 +21,5 @@ Knapsack Maximum Weight: 10 ``` For the above, the first item has weight 5 and value 10, the second item has weight 4 and value 40, and so on. -In this example, Bob should take the second and fourth item to maximize his value, which, in this case, is 90. -He cannot get more than 90 as his knapsack has a weight limit of 10. +In this example, Lhakpa should take the second and fourth item to maximize her value, which, in this case, is 90. +She cannot get more than 90 as her knapsack has a weight limit of 10. diff --git a/exercises/practice/knapsack/.docs/introduction.md b/exercises/practice/knapsack/.docs/introduction.md index 9b2bed8..9ac9df5 100644 --- a/exercises/practice/knapsack/.docs/introduction.md +++ b/exercises/practice/knapsack/.docs/introduction.md @@ -1,8 +1,10 @@ # Introduction -Bob is a thief. -After months of careful planning, he finally manages to crack the security systems of a fancy store. +Lhakpa is a [Sherpa][sherpa] mountain guide and porter. +After months of careful planning, the expedition Lhakpa works for is about to leave. +She will be paid the value she carried to the base camp. -In front of him are many items, each with a value and weight. -Bob would gladly take all of the items, but his knapsack can only hold so much weight. -Bob has to carefully consider which items to take so that the total value of his selection is maximized. +In front of her are many items, each with a value and weight. +Lhakpa would gladly take all of the items, but her knapsack can only hold so much weight. + +[sherpa]: https://en.wikipedia.org/wiki/Sherpa_people#Mountaineering diff --git a/exercises/practice/knapsack/.meta/tests.toml b/exercises/practice/knapsack/.meta/tests.toml index febc7b2..8e013ef 100644 --- a/exercises/practice/knapsack/.meta/tests.toml +++ b/exercises/practice/knapsack/.meta/tests.toml @@ -11,6 +11,11 @@ [a4d7d2f0-ad8a-460c-86f3-88ba709d41a7] description = "no items" +include = false + +[3993a824-c20e-493d-b3c9-ee8a7753ee59] +description = "no items" +reimplements = "a4d7d2f0-ad8a-460c-86f3-88ba709d41a7" [1d39e98c-6249-4a8b-912f-87cb12e506b0] description = "one item, too heavy" diff --git a/exercises/practice/largest-series-product/.meta/tests.toml b/exercises/practice/largest-series-product/.meta/tests.toml new file mode 100644 index 0000000..5a62d61 --- /dev/null +++ b/exercises/practice/largest-series-product/.meta/tests.toml @@ -0,0 +1,70 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[7c82f8b7-e347-48ee-8a22-f672323324d4] +description = "finds the largest product if span equals length" + +[88523f65-21ba-4458-a76a-b4aaf6e4cb5e] +description = "can find the largest product of 2 with numbers in order" + +[f1376b48-1157-419d-92c2-1d7e36a70b8a] +description = "can find the largest product of 2" + +[46356a67-7e02-489e-8fea-321c2fa7b4a4] +description = "can find the largest product of 3 with numbers in order" + +[a2dcb54b-2b8f-4993-92dd-5ce56dece64a] +description = "can find the largest product of 3" + +[673210a3-33cd-4708-940b-c482d7a88f9d] +description = "can find the largest product of 5 with numbers in order" + +[02acd5a6-3bbf-46df-8282-8b313a80a7c9] +description = "can get the largest product of a big number" + +[76dcc407-21e9-424c-a98e-609f269622b5] +description = "reports zero if the only digits are zero" + +[6ef0df9f-52d4-4a5d-b210-f6fae5f20e19] +description = "reports zero if all spans include zero" + +[5d81aaf7-4f67-4125-bf33-11493cc7eab7] +description = "rejects span longer than string length" +include = false + +[0ae1ce53-d9ba-41bb-827f-2fceb64f058b] +description = "rejects span longer than string length" +reimplements = "5d81aaf7-4f67-4125-bf33-11493cc7eab7" + +[06bc8b90-0c51-4c54-ac22-3ec3893a079e] +description = "reports 1 for empty string and empty product (0 span)" + +[3ec0d92e-f2e2-4090-a380-70afee02f4c0] +description = "reports 1 for nonempty string and empty product (0 span)" + +[6d96c691-4374-4404-80ee-2ea8f3613dd4] +description = "rejects empty string and nonzero span" +include = false + +[6cf66098-a6af-4223-aab1-26aeeefc7402] +description = "rejects empty string and nonzero span" +reimplements = "6d96c691-4374-4404-80ee-2ea8f3613dd4" + +[7a38f2d6-3c35-45f6-8d6f-12e6e32d4d74] +description = "rejects invalid character in digits" + +[5fe3c0e5-a945-49f2-b584-f0814b4dd1ef] +description = "rejects negative span" +include = false + +[c859f34a-9bfe-4897-9c2f-6d7f8598e7f0] +description = "rejects negative span" +reimplements = "5fe3c0e5-a945-49f2-b584-f0814b4dd1ef" diff --git a/exercises/practice/leap/.meta/config.json b/exercises/practice/leap/.meta/config.json index 0a52cd5..591dc85 100644 --- a/exercises/practice/leap/.meta/config.json +++ b/exercises/practice/leap/.meta/config.json @@ -15,5 +15,5 @@ }, "blurb": "Determine whether a given year is a leap year.", "source": "CodeRanch Cattle Drive, Assignment 3", - "source_url": "https://coderanch.com/t/718816/Leap" + "source_url": "https://web.archive.org/web/20240907033714/https://coderanch.com/t/718816/Leap" } diff --git a/exercises/practice/leap/.meta/tests.toml b/exercises/practice/leap/.meta/tests.toml new file mode 100644 index 0000000..ce6ba32 --- /dev/null +++ b/exercises/practice/leap/.meta/tests.toml @@ -0,0 +1,37 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[6466b30d-519c-438e-935d-388224ab5223] +description = "year not divisible by 4 in common year" + +[ac227e82-ee82-4a09-9eb6-4f84331ffdb0] +description = "year divisible by 2, not divisible by 4 in common year" + +[4fe9b84c-8e65-489e-970b-856d60b8b78e] +description = "year divisible by 4, not divisible by 100 in leap year" + +[7fc6aed7-e63c-48f5-ae05-5fe182f60a5d] +description = "year divisible by 4 and 5 is still a leap year" + +[78a7848f-9667-4192-ae53-87b30c9a02dd] +description = "year divisible by 100, not divisible by 400 in common year" + +[9d70f938-537c-40a6-ba19-f50739ce8bac] +description = "year divisible by 100 but not by 3 is still not a leap year" + +[42ee56ad-d3e6-48f1-8e3f-c84078d916fc] +description = "year divisible by 400 is leap year" + +[57902c77-6fe9-40de-8302-587b5c27121e] +description = "year divisible by 400 but not by 125 is still a leap year" + +[c30331f6-f9f6-4881-ad38-8ca8c12520c1] +description = "year divisible by 200, not divisible by 400 in common year" diff --git a/exercises/practice/matching-brackets/.docs/instructions.md b/exercises/practice/matching-brackets/.docs/instructions.md index 364ecad..ea17084 100644 --- a/exercises/practice/matching-brackets/.docs/instructions.md +++ b/exercises/practice/matching-brackets/.docs/instructions.md @@ -1,5 +1,5 @@ # Instructions -Given a string containing brackets `[]`, braces `{}`, parentheses `()`, -or any combination thereof, verify that any and all pairs are matched -and nested correctly. +Given a string containing brackets `[]`, braces `{}`, parentheses `()`, or any combination thereof, verify that any and all pairs are matched and nested correctly. +Any other characters should be ignored. +For example, `"{what is (42)}?"` is balanced and `"[text}"` is not. diff --git a/exercises/practice/matching-brackets/.docs/introduction.md b/exercises/practice/matching-brackets/.docs/introduction.md new file mode 100644 index 0000000..0618221 --- /dev/null +++ b/exercises/practice/matching-brackets/.docs/introduction.md @@ -0,0 +1,8 @@ +# Introduction + +You're given the opportunity to write software for the Bracketeer™, an ancient but powerful mainframe. +The software that runs on it is written in a proprietary language. +Much of its syntax is familiar, but you notice _lots_ of brackets, braces and parentheses. +Despite the Bracketeer™ being powerful, it lacks flexibility. +If the source code has any unbalanced brackets, braces or parentheses, the Bracketeer™ crashes and must be rebooted. +To avoid such a scenario, you start writing code that can verify that brackets, braces, and parentheses are balanced before attempting to run it on the Bracketeer™. diff --git a/exercises/practice/matching-brackets/.meta/testAnnotation.json b/exercises/practice/matching-brackets/.meta/testAnnotation.json index 8e43919..f8498df 100644 --- a/exercises/practice/matching-brackets/.meta/testAnnotation.json +++ b/exercises/practice/matching-brackets/.meta/testAnnotation.json @@ -74,5 +74,9 @@ { "name": "complex latex expression", "test_code": "verify do\n labeled \"complex latex expression\" do\n expected = true\n actual = isPaired \"\\\\left(\\\\begin{array}{cc} \\\\frac{1}{3} & x\\\\\\\\ \\\\mathrm{e}^{x} &... x^2 \\\\end{array}\\\\right)\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" + }, + { + "name": "paired and wrong nested brackets but innermost are correct", + "test_code": "verify do\n labeled \"paired and wrong nested brackets but innermost are correct\" do\n expected = false\n actual = isPaired \"[({}])\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } ] diff --git a/exercises/practice/matching-brackets/.meta/tests.toml b/exercises/practice/matching-brackets/.meta/tests.toml index da13147..35a98a0 100644 --- a/exercises/practice/matching-brackets/.meta/tests.toml +++ b/exercises/practice/matching-brackets/.meta/tests.toml @@ -48,6 +48,9 @@ description = "unpaired and nested brackets" [a0205e34-c2ac-49e6-a88a-899508d7d68e] description = "paired and wrong nested brackets" +[1d5c093f-fc84-41fb-8c2a-e052f9581602] +description = "paired and wrong nested brackets but innermost are correct" + [ef47c21b-bcfd-4998-844c-7ad5daad90a8] description = "paired and incomplete brackets" diff --git a/exercises/practice/matching-brackets/matchingBrackets.test.u b/exercises/practice/matching-brackets/matchingBrackets.test.u index c6badfb..47ba156 100644 --- a/exercises/practice/matching-brackets/matchingBrackets.test.u +++ b/exercises/practice/matching-brackets/matchingBrackets.test.u @@ -150,6 +150,14 @@ matchingBrackets.test.ex19 = verify do label "actual" actual ensureEqual expected actual +matchingBrackets.test.ex20 = verify do + labeled "paired and wrong nested brackets but innermost are correct" do + expected = false + actual = isPaired "[({}])" + label "expected" expected + label "actual" actual + ensureEqual expected actual + test> matchingBrackets.tests = join [ matchingBrackets.test.ex1, matchingBrackets.test.ex2, @@ -169,5 +177,6 @@ test> matchingBrackets.tests = join [ matchingBrackets.test.ex16, matchingBrackets.test.ex17, matchingBrackets.test.ex18, - matchingBrackets.test.ex19 + matchingBrackets.test.ex19, + matchingBrackets.test.ex20 ] diff --git a/exercises/practice/pig-latin/.meta/testAnnotation.json b/exercises/practice/pig-latin/.meta/testAnnotation.json index 1384601..3b8bfb3 100644 --- a/exercises/practice/pig-latin/.meta/testAnnotation.json +++ b/exercises/practice/pig-latin/.meta/testAnnotation.json @@ -86,5 +86,9 @@ { "name": "phrases are translated - a whole phrase", "test_code": "verify do\n labeled \"phrases are translated - a whole phrase\" do\n expected = \"ickquay astfay unray\"\n actual = pigLatin.translate \"quick fast run\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" + }, + { + "name": "first letter and ay are moved to the end of words that start with consonants - word beginning with consonant and vowel containing qu", + "test_code": "verify do\n labeled \"first letter and ay are moved to the end of words that start with consonants - word beginning with consonant and vowel containing qu\" do\n expected = \"iquidlay\"\n actual = pigLatin.translate \"liquid\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } ] diff --git a/exercises/practice/pig-latin/.meta/tests.toml b/exercises/practice/pig-latin/.meta/tests.toml index c29168c..d524305 100644 --- a/exercises/practice/pig-latin/.meta/tests.toml +++ b/exercises/practice/pig-latin/.meta/tests.toml @@ -39,6 +39,9 @@ description = "first letter and ay are moved to the end of words that start with [bce94a7a-a94e-4e2b-80f4-b2bb02e40f71] description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with q without a following u" +[e59dbbe8-ccee-4619-a8e9-ce017489bfc0] +description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with consonant and vowel containing qu" + [c01e049a-e3e2-451c-bf8e-e2abb7e438b8] description = "some letter clusters are treated like a single consonant -> word beginning with ch" diff --git a/exercises/practice/pig-latin/pigLatin.test.u b/exercises/practice/pig-latin/pigLatin.test.u index a4b6240..41e2ea8 100644 --- a/exercises/practice/pig-latin/pigLatin.test.u +++ b/exercises/practice/pig-latin/pigLatin.test.u @@ -174,6 +174,14 @@ pigLatin.translate.tests.ex22 = verify do label "actual" actual ensureEqual expected actual +pigLatin.translate.tests.ex23 = verify do + labeled "first letter and ay are moved to the end of words that start with consonants - word beginning with consonant and vowel containing qu" do + expected = "iquidlay" + actual = pigLatin.translate "liquid" + label "expected" expected + label "actual" actual + ensureEqual expected actual + test> pigLatin.tests = join [ pigLatin.translate.tests.ex1, pigLatin.translate.tests.ex2, @@ -196,5 +204,6 @@ test> pigLatin.tests = join [ pigLatin.translate.tests.ex19, pigLatin.translate.tests.ex20, pigLatin.translate.tests.ex21, - pigLatin.translate.tests.ex22 + pigLatin.translate.tests.ex22, + pigLatin.translate.tests.ex23 ] diff --git a/exercises/practice/protein-translation/.docs/instructions.md b/exercises/practice/protein-translation/.docs/instructions.md index d9b9054..35c953b 100644 --- a/exercises/practice/protein-translation/.docs/instructions.md +++ b/exercises/practice/protein-translation/.docs/instructions.md @@ -1,44 +1,37 @@ # Instructions -Translate RNA sequences into proteins. - -RNA can be broken into three nucleotide sequences called codons, and then translated to a polypeptide like so: - -RNA: `"AUGUUUUCU"` => translates to - -Codons: `"AUG", "UUU", "UCU"` -=> which become a polypeptide with the following sequence => - -Protein: `"Methionine", "Phenylalanine", "Serine"` - -There are 64 codons which in turn correspond to 20 amino acids; however, all of the codon sequences and resulting amino acids are not important in this exercise. -If it works for one codon, the program should work for all of them. -However, feel free to expand the list in the test suite to include them all. - -There are also three terminating codons (also known as 'STOP' codons); if any of these codons are encountered (by the ribosome), all translation ends and the protein is terminated. - -All subsequent codons after are ignored, like this: - -RNA: `"AUGUUUUCUUAAAUG"` => - -Codons: `"AUG", "UUU", "UCU", "UAA", "AUG"` => - -Protein: `"Methionine", "Phenylalanine", "Serine"` - -Note the stop codon `"UAA"` terminates the translation and the final methionine is not translated into the protein sequence. - -Below are the codons and resulting Amino Acids needed for the exercise. - -Codon | Protein -:--- | :--- -AUG | Methionine -UUU, UUC | Phenylalanine -UUA, UUG | Leucine -UCU, UCC, UCA, UCG | Serine -UAU, UAC | Tyrosine -UGU, UGC | Cysteine -UGG | Tryptophan -UAA, UAG, UGA | STOP +Your job is to translate RNA sequences into proteins. + +RNA strands are made up of three-nucleotide sequences called **codons**. +Each codon translates to an **amino acid**. +When joined together, those amino acids make a protein. + +In the real world, there are 64 codons, which in turn correspond to 20 amino acids. +However, for this exercise, you’ll only use a few of the possible 64. +They are listed below: + +| Codon | Amino Acid | +| ------------------ | ------------- | +| AUG | Methionine | +| UUU, UUC | Phenylalanine | +| UUA, UUG | Leucine | +| UCU, UCC, UCA, UCG | Serine | +| UAU, UAC | Tyrosine | +| UGU, UGC | Cysteine | +| UGG | Tryptophan | +| UAA, UAG, UGA | STOP | + +For example, the RNA string “AUGUUUUCU” has three codons: “AUG”, “UUU” and “UCU”. +These map to Methionine, Phenylalanine, and Serine. + +## “STOP” Codons + +You’ll note from the table above that there are three **“STOP” codons**. +If you encounter any of these codons, ignore the rest of the sequence — the protein is complete. + +For example, “AUGUUUUCUUAAAUG” contains a STOP codon (“UAA”). +Once we reach that point, we stop processing. +We therefore only consider the part before it (i.e. “AUGUUUUCU”), not any further codons after it (i.e. “AUG”). Learn more about [protein translation on Wikipedia][protein-translation]. diff --git a/exercises/practice/protein-translation/.meta/testAnnotation.json b/exercises/practice/protein-translation/.meta/testAnnotation.json index 7f2f526..205dd69 100644 --- a/exercises/practice/protein-translation/.meta/testAnnotation.json +++ b/exercises/practice/protein-translation/.meta/testAnnotation.json @@ -102,5 +102,9 @@ { "name": "Translation stops if STOP codon in middle of six-codon sequence", "test_code": "verify do\n labeled \"Translation stops if STOP codon in middle of six-codon sequence\" do\n expected = [\"Tryptophan\", \"Cysteine\", \"Tyrosine\"]\n actual = proteins \"UGGUGUUAUUAAUGGUUU\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" + }, + { + "name": "Sequence of two non-STOP codons does not translate to a STOP codon", + "test_code": "verify do\n labeled \"Sequence of two non-STOP codons does not translate to a STOP codon\" do\n expected = [\"Methionine\", \"Methionine\"]\n actual = proteins \"AUGAUG\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } ] diff --git a/exercises/practice/protein-translation/.meta/tests.toml b/exercises/practice/protein-translation/.meta/tests.toml index 5fb1890..93a3cc7 100644 --- a/exercises/practice/protein-translation/.meta/tests.toml +++ b/exercises/practice/protein-translation/.meta/tests.toml @@ -87,11 +87,16 @@ description = "Translation stops if STOP codon in middle of three-codon sequence [2c2a2a60-401f-4a80-b977-e0715b23b93d] description = "Translation stops if STOP codon in middle of six-codon sequence" +[f6f92714-769f-4187-9524-e353e8a41a80] +description = "Sequence of two non-STOP codons does not translate to a STOP codon" + [1e75ea2a-f907-4994-ae5c-118632a1cb0f] description = "Non-existing codon can't translate" [9eac93f3-627a-4c90-8653-6d0a0595bc6f] description = "Unknown amino acids, not part of a codon, can't translate" +reimplements = "1e75ea2a-f907-4994-ae5c-118632a1cb0f" +comment = "Excluded, because it requires an input validation." [9d73899f-e68e-4291-b1e2-7bf87c00f024] description = "Incomplete RNA sequence can't translate" diff --git a/exercises/practice/protein-translation/proteinTranslation.test.u b/exercises/practice/protein-translation/proteinTranslation.test.u index 12ba603..85bd0e9 100644 --- a/exercises/practice/protein-translation/proteinTranslation.test.u +++ b/exercises/practice/protein-translation/proteinTranslation.test.u @@ -206,6 +206,14 @@ proteinTranslation.test.ex26 = verify do label "actual" actual ensureEqual expected actual +proteinTranslation.test.ex27 = verify do + labeled "Sequence of two non-STOP codons does not translate to a STOP codon" do + expected = ["Methionine", "Methionine"] + actual = proteins "AUGAUG" + label "expected" expected + label "actual" actual + ensureEqual expected actual + test> proteinTranslation.tests = join [ proteinTranslation.test.ex1, proteinTranslation.test.ex2, @@ -232,5 +240,6 @@ test> proteinTranslation.tests = join [ proteinTranslation.test.ex23, proteinTranslation.test.ex24, proteinTranslation.test.ex25, - proteinTranslation.test.ex26 + proteinTranslation.test.ex26, + proteinTranslation.test.ex27 ] diff --git a/exercises/practice/raindrops/.meta/config.json b/exercises/practice/raindrops/.meta/config.json index 703907e..5a12988 100644 --- a/exercises/practice/raindrops/.meta/config.json +++ b/exercises/practice/raindrops/.meta/config.json @@ -13,7 +13,7 @@ ".meta/examples/raindrops.example.u" ] }, - "blurb": "Convert a number to a string, the content of which depends on the number's factors.", + "blurb": "Convert a number into its corresponding raindrop sounds - Pling, Plang and Plong.", "source": "A variation on FizzBuzz, a famous technical interview question that is intended to weed out potential candidates. That question is itself derived from Fizz Buzz, a popular children's game for teaching division.", "source_url": "https://en.wikipedia.org/wiki/Fizz_buzz" } diff --git a/exercises/practice/raindrops/.meta/tests.toml b/exercises/practice/raindrops/.meta/tests.toml new file mode 100644 index 0000000..756d16c --- /dev/null +++ b/exercises/practice/raindrops/.meta/tests.toml @@ -0,0 +1,64 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[1575d549-e502-46d4-a8e1-6b7bec6123d8] +description = "the sound for 1 is 1" + +[1f51a9f9-4895-4539-b182-d7b0a5ab2913] +description = "the sound for 3 is Pling" + +[2d9bfae5-2b21-4bcd-9629-c8c0e388f3e0] +description = "the sound for 5 is Plang" + +[d7e60daa-32ef-4c23-b688-2abff46c4806] +description = "the sound for 7 is Plong" + +[6bb4947b-a724-430c-923f-f0dc3d62e56a] +description = "the sound for 6 is Pling as it has a factor 3" + +[ce51e0e8-d9d4-446d-9949-96eac4458c2d] +description = "2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base" + +[0dd66175-e3e2-47fc-8750-d01739856671] +description = "the sound for 9 is Pling as it has a factor 3" + +[022c44d3-2182-4471-95d7-c575af225c96] +description = "the sound for 10 is Plang as it has a factor 5" + +[37ab74db-fed3-40ff-b7b9-04acdfea8edf] +description = "the sound for 14 is Plong as it has a factor of 7" + +[31f92999-6afb-40ee-9aa4-6d15e3334d0f] +description = "the sound for 15 is PlingPlang as it has factors 3 and 5" + +[ff9bb95d-6361-4602-be2c-653fe5239b54] +description = "the sound for 21 is PlingPlong as it has factors 3 and 7" + +[d2e75317-b72e-40ab-8a64-6734a21dece1] +description = "the sound for 25 is Plang as it has a factor 5" + +[a09c4c58-c662-4e32-97fe-f1501ef7125c] +description = "the sound for 27 is Pling as it has a factor 3" + +[bdf061de-8564-4899-a843-14b48b722789] +description = "the sound for 35 is PlangPlong as it has factors 5 and 7" + +[c4680bee-69ba-439d-99b5-70c5fd1a7a83] +description = "the sound for 49 is Plong as it has a factor 7" + +[17f2bc9a-b65a-4d23-8ccd-266e8c271444] +description = "the sound for 52 is 52" + +[e46677ed-ff1a-419f-a740-5c713d2830e4] +description = "the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7" + +[13c6837a-0fcd-4b86-a0eb-20572f7deb0b] +description = "the sound for 3125 is Plang as it has a factor 5" diff --git a/exercises/practice/reverse-string/.meta/testAnnotation.json b/exercises/practice/reverse-string/.meta/testAnnotation.json index 4a8fdc6..7d6beb4 100644 --- a/exercises/practice/reverse-string/.meta/testAnnotation.json +++ b/exercises/practice/reverse-string/.meta/testAnnotation.json @@ -22,5 +22,9 @@ { "name": "An even-sized word", "test_code": "verify do\n labeled \"An even-sized word\" do\n expected = \"reward\"\n actual = reverseString.reverse \"drawer\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" + }, + { + "name": "wide characters", + "test_code": "verify do\n labeled \"wide characters\" do\n expected = \"猫子\"\n actual = reverseString.reverse \"子猫\"\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } ] diff --git a/exercises/practice/reverse-string/.meta/tests.toml b/exercises/practice/reverse-string/.meta/tests.toml index 0b04c4c..e8a5ba6 100644 --- a/exercises/practice/reverse-string/.meta/tests.toml +++ b/exercises/practice/reverse-string/.meta/tests.toml @@ -26,3 +26,14 @@ description = "a palindrome" [b9e7dec1-c6df-40bd-9fa3-cd7ded010c4c] description = "an even-sized word" + +[1bed0f8a-13b0-4bd3-9d59-3d0593326fa2] +description = "wide characters" + +[93d7e1b8-f60f-4f3c-9559-4056e10d2ead] +description = "grapheme cluster with pre-combined form" +comment = "currently Unison doesn't support grapheme clusters" + +[1028b2c1-6763-4459-8540-2da47ca512d9] +description = "grapheme clusters" +comment = "currently Unison doesn't support grapheme clusters" diff --git a/exercises/practice/reverse-string/reverseString.test.u b/exercises/practice/reverse-string/reverseString.test.u index 1442f4e..2ae1a1d 100644 --- a/exercises/practice/reverse-string/reverseString.test.u +++ b/exercises/practice/reverse-string/reverseString.test.u @@ -46,11 +46,20 @@ reverseString.test.ex6 = verify do label "actual" actual ensureEqual expected actual +reverseString.test.ex7 = verify do + labeled "wide characters" do + expected = "猫子" + actual = reverseString.reverse "子猫" + label "expected" expected + label "actual" actual + ensureEqual expected actual + test> reverseString.tests = join [ reverseString.test.ex1, reverseString.test.ex2, reverseString.test.ex3, reverseString.test.ex4, reverseString.test.ex5, - reverseString.test.ex6 + reverseString.test.ex6, + reverseString.test.ex7 ] diff --git a/exercises/practice/roman-numerals/.meta/testAnnotation.json b/exercises/practice/roman-numerals/.meta/testAnnotation.json index c24e18f..dec4ed0 100644 --- a/exercises/practice/roman-numerals/.meta/testAnnotation.json +++ b/exercises/practice/roman-numerals/.meta/testAnnotation.json @@ -102,5 +102,9 @@ { "name": "3999 is MMMCMXCIX", "test_code": "verify do\n labeled \"3999 is MMMCMXCIX\" do\n expected = \"MMMCMXCIX\"\n actual = toRoman 3999\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" + }, + { + "name": "3888 is MMMDCCCLXXXVIII", + "test_code": "verify do\n labeled \"3888 is MMMDCCCLXXXVIII\" do\n expected = \"MMMDCCCLXXXVIII\"\n actual = toRoman 3888\n label \"expected\" expected\n label \"actual\" actual\n ensureEqual expected actual" } ] diff --git a/exercises/practice/roman-numerals/.meta/tests.toml b/exercises/practice/roman-numerals/.meta/tests.toml index 57c6c4b..709011b 100644 --- a/exercises/practice/roman-numerals/.meta/tests.toml +++ b/exercises/practice/roman-numerals/.meta/tests.toml @@ -84,5 +84,8 @@ description = "3000 is MMM" [3bc4b41c-c2e6-49d9-9142-420691504336] description = "3001 is MMMI" +[2f89cad7-73f6-4d1b-857b-0ef531f68b7e] +description = "3888 is MMMDCCCLXXXVIII" + [4e18e96b-5fbb-43df-a91b-9cb511fe0856] description = "3999 is MMMCMXCIX" diff --git a/exercises/practice/roman-numerals/romanNumerals.test.u b/exercises/practice/roman-numerals/romanNumerals.test.u index 8198f0d..0e12f3e 100644 --- a/exercises/practice/roman-numerals/romanNumerals.test.u +++ b/exercises/practice/roman-numerals/romanNumerals.test.u @@ -206,6 +206,14 @@ romanNumerals.test.ex26 = verify do label "actual" actual ensureEqual expected actual +romanNumerals.test.ex27 = verify do + labeled "3888 is MMMDCCCLXXXVIII" do + expected = "MMMDCCCLXXXVIII" + actual = toRoman 3888 + label "expected" expected + label "actual" actual + ensureEqual expected actual + test> romanNumerals.tests = join [ romanNumerals.test.ex1, romanNumerals.test.ex2, @@ -232,5 +240,6 @@ test> romanNumerals.tests = join [ romanNumerals.test.ex23, romanNumerals.test.ex24, romanNumerals.test.ex25, - romanNumerals.test.ex26 + romanNumerals.test.ex26, + romanNumerals.test.ex27 ] diff --git a/exercises/practice/run-length-encoding/.docs/instructions.md b/exercises/practice/run-length-encoding/.docs/instructions.md index 95f7a9d..fc8ce05 100644 --- a/exercises/practice/run-length-encoding/.docs/instructions.md +++ b/exercises/practice/run-length-encoding/.docs/instructions.md @@ -2,8 +2,7 @@ Implement run-length encoding and decoding. -Run-length encoding (RLE) is a simple form of data compression, where runs -(consecutive data elements) are replaced by just one data value and count. +Run-length encoding (RLE) is a simple form of data compression, where runs (consecutive data elements) are replaced by just one data value and count. For example we can represent the original 53 characters with only 13. @@ -11,14 +10,11 @@ For example we can represent the original 53 characters with only 13. "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" -> "12WB12W3B24WB" ``` -RLE allows the original data to be perfectly reconstructed from -the compressed data, which makes it a lossless data compression. +RLE allows the original data to be perfectly reconstructed from the compressed data, which makes it a lossless data compression. ```text "AABCCCDEEEE" -> "2AB3CD4E" -> "AABCCCDEEEE" ``` -For simplicity, you can assume that the unencoded string will only contain -the letters A through Z (either lower or upper case) and whitespace. This way -data to be encoded will never contain any numbers and numbers inside data to -be decoded always represent the count for the following character. +For simplicity, you can assume that the unencoded string will only contain the letters A through Z (either lower or upper case) and whitespace. +This way data to be encoded will never contain any numbers and numbers inside data to be decoded always represent the count for the following character. diff --git a/exercises/practice/run-length-encoding/.meta/tests.toml b/exercises/practice/run-length-encoding/.meta/tests.toml index 894f306..7bdb808 100644 --- a/exercises/practice/run-length-encoding/.meta/tests.toml +++ b/exercises/practice/run-length-encoding/.meta/tests.toml @@ -9,6 +9,9 @@ # As user-added comments (using the # character) will be removed when this file # is regenerated, comments can be added via a `comment` key. +[ad53b61b-6ffc-422f-81a6-61f7df92a231] +description = "run-length encode a string -> empty string" + [52012823-b7e6-4277-893c-5b96d42f82de] description = "run-length encode a string -> single characters only are encoded without count" diff --git a/exercises/practice/zipper/.docs/instructions.md b/exercises/practice/zipper/.docs/instructions.md index e0dcafb..5445db0 100644 --- a/exercises/practice/zipper/.docs/instructions.md +++ b/exercises/practice/zipper/.docs/instructions.md @@ -2,13 +2,10 @@ Creating a zipper for a binary tree. -[Zippers](https://en.wikipedia.org/wiki/Zipper_%28data_structure%29) are -a purely functional way of navigating within a data structure and -manipulating it. They essentially contain a data structure and a -pointer into that data structure (called the focus). +[Zippers][zipper] are a purely functional way of navigating within a data structure and manipulating it. +They essentially contain a data structure and a pointer into that data structure (called the focus). -For example, given a rose tree (where each node contains a value and a -list of child nodes) a zipper might support these operations: +For example given a rose tree (where each node contains a value and a list of child nodes) a zipper might support these operations: - `from_tree` (get a zipper out of a rose tree, the focus is on the root node) - `to_tree` (get the rose tree out of the zipper) @@ -26,3 +23,5 @@ list of child nodes) a zipper might support these operations: - `delete` (removes the focus node and all subtrees, focus moves to the `next` node if possible otherwise to the `prev` node if possible, otherwise to the parent node, returns a new zipper) + +[zipper]: https://en.wikipedia.org/wiki/Zipper_%28data_structure%29 diff --git a/exercises/practice/zipper/.meta/config.json b/exercises/practice/zipper/.meta/config.json index 19ca2f7..87248ee 100644 --- a/exercises/practice/zipper/.meta/config.json +++ b/exercises/practice/zipper/.meta/config.json @@ -13,5 +13,5 @@ ".meta/examples/zipper.example.u" ] }, - "blurb": "Create a zipper for traversing and changing the nodes of a binary tree" + "blurb": "Creating a zipper for a binary tree." } diff --git a/exercises/practice/zipper/.meta/tests.toml b/exercises/practice/zipper/.meta/tests.toml new file mode 100644 index 0000000..e93932b --- /dev/null +++ b/exercises/practice/zipper/.meta/tests.toml @@ -0,0 +1,52 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[771c652e-0754-4ef0-945c-0675d12ef1f5] +description = "data is retained" + +[d7dcbb92-47fc-4d01-b81a-df3353bc09ff] +description = "left, right and value" + +[613d8286-b05c-4453-b205-e6f9c5966339] +description = "dead end" + +[dda31af7-1c68-4e29-933a-c9d198d94284] +description = "tree from deep focus" + +[1e3072a6-f85b-430b-b014-cdb4087e3577] +description = "traversing up from top" + +[b8505f6a-aed4-4c2e-824f-a0ed8570d74b] +description = "left, right, and up" + +[b9aa8d54-07b7-4bfd-ab6b-7ff7f35930b6] +description = "test ability to descend multiple levels and return" + +[47df1a27-b709-496e-b381-63a03b82ea5f] +description = "set_value" + +[16a1f1a8-dbed-456d-95ac-1cbb6093e0ab] +description = "set_value after traversing up" + +[535a91af-a02e-49cd-8d2c-ecb6e4647174] +description = "set_left with leaf" + +[b3f60c4b-a788-4ffd-be5d-1e69aee61de3] +description = "set_right with null" + +[e91c221d-7b90-4604-b4ec-46638a673a12] +description = "set_right with subtree" + +[c246be85-6648-4e9c-866f-b08cd495149a] +description = "set_value on deep focus" + +[47aa85a0-5240-48a4-9f42-e2ac636710ea] +description = "different paths to same zipper"