Skip to content

Commit d58142d

Browse files
authored
Sync problem specs (#374)
1 parent 79e30cd commit d58142d

File tree

14 files changed

+119
-49
lines changed

14 files changed

+119
-49
lines changed

exercises/practice/binary-search-tree/.docs/instructions.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,52 @@ All data in the left subtree is less than or equal to the current node's data, a
1919

2020
For example, if we had a node containing the data 4, and we added the data 2, our tree would look like this:
2121

22+
![A graph with root node 4 and a single child node 2.](https://assets.exercism.org/images/exercises/binary-search-tree/tree-4-2.svg)
23+
24+
```text
2225
4
2326
/
2427
2
28+
```
2529

2630
If we then added 6, it would look like this:
2731

32+
![A graph with root node 4 and two child nodes 2 and 6.](https://assets.exercism.org/images/exercises/binary-search-tree/tree-4-2-6.svg)
33+
34+
```text
2835
4
2936
/ \
3037
2 6
38+
```
3139

3240
If we then added 3, it would look like this
3341

42+
![A graph with root node 4, two child nodes 2 and 6, and a grandchild node 3.](https://assets.exercism.org/images/exercises/binary-search-tree/tree-4-2-6-3.svg)
43+
44+
```text
3445
4
3546
/ \
3647
2 6
3748
\
3849
3
50+
```
3951

4052
And if we then added 1, 5, and 7, it would look like this
4153

54+
![A graph with root node 4, two child nodes 2 and 6, and four grandchild nodes 1, 3, 5 and 7.](https://assets.exercism.org/images/exercises/binary-search-tree/tree-4-2-6-1-3-5-7.svg)
55+
56+
```text
4257
4
4358
/ \
4459
/ \
4560
2 6
4661
/ \ / \
4762
1 3 5 7
63+
```
64+
65+
## Credit
66+
67+
The images were created by [habere-et-dispertire][habere-et-dispertire] using [PGF/TikZ][pgf-tikz] by Till Tantau.
68+
69+
[habere-et-dispertire]: https://exercism.org/profiles/habere-et-dispertire
70+
[pgf-tikz]: https://en.wikipedia.org/wiki/PGF/TikZ

exercises/practice/eliuds-eggs/.docs/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The position information encoding is calculated as follows:
5858

5959
### Decimal number on the display
6060

61-
16
61+
8
6262

6363
### Actual eggs in the coop
6464

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# Instructions
22

3-
Take a nested list and return a single flattened list with all values except nil/null.
3+
Take a nested array of any depth and return a fully flattened array.
44

5-
The challenge is to take an arbitrarily-deep nested list-like structure and produce a flattened structure without any nil/null values.
5+
Note that some language tracks may include null-like values in the input array, and the way these values are represented varies by track.
6+
Such values should be excluded from the flattened array.
67

7-
For example:
8+
Additionally, the input may be of a different data type and contain different types, depending on the track.
89

9-
input: [1,[2,3,null,4],[null],5]
10+
Check the test suite for details.
1011

11-
output: [1,2,3,4,5]
12+
## Example
13+
14+
input: `[1, [2, 6, null], [[null, [4]], 5]]`
15+
16+
output: `[1, 2, 6, 4, 5]`
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Introduction
2+
3+
A shipment of emergency supplies has arrived, but there's a problem.
4+
To protect from damage, the items — flashlights, first-aid kits, blankets — are packed inside boxes, and some of those boxes are nested several layers deep inside other boxes!
5+
6+
To be prepared for an emergency, everything must be easily accessible in one box.
7+
Can you unpack all the supplies and place them into a single box, so they're ready when needed most?

exercises/practice/flatten-array/.meta/tests.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,32 @@ description = "null values are omitted from the final result"
3232

3333
[c6cf26de-8ccd-4410-84bd-b9efd88fd2bc]
3434
description = "consecutive null values at the front of the list are omitted from the final result"
35+
include = false
36+
37+
[bc72da10-5f55-4ada-baf3-50e4da02ec8e]
38+
description = "consecutive null values at the front of the array are omitted from the final result"
39+
reimplements = "c6cf26de-8ccd-4410-84bd-b9efd88fd2bc"
3540

3641
[382c5242-587e-4577-b8ce-a5fb51e385a1]
3742
description = "consecutive null values in the middle of the list are omitted from the final result"
43+
include = false
44+
45+
[6991836d-0d9b-4703-80a0-3f1f23eb5981]
46+
description = "consecutive null values in the middle of the array are omitted from the final result"
47+
reimplements = "382c5242-587e-4577-b8ce-a5fb51e385a1"
3848

3949
[ef1d4790-1b1e-4939-a179-51ace0829dbd]
4050
description = "6 level nest list with null values"
51+
include = false
52+
53+
[dc90a09c-5376-449c-a7b3-c2d20d540069]
54+
description = "6 level nested array with null values"
55+
reimplements = "ef1d4790-1b1e-4939-a179-51ace0829dbd"
4156

4257
[85721643-705a-4150-93ab-7ae398e2942d]
4358
description = "all values in nested list are null"
59+
include = false
60+
61+
[51f5d9af-8f7f-4fb5-a156-69e8282cb275]
62+
description = "all values in nested array are null"
63+
reimplements = "85721643-705a-4150-93ab-7ae398e2942d"

exercises/practice/flatten-array/flatten-array.spec.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ describe 'Flatten Array', ->
3131
expected = [1, 2]
3232
expect(FlattenArray.flatten values).toEqual expected
3333

34-
xit 'consecutive null values at the front of the list are omitted from the final result', ->
34+
xit 'consecutive null values at the front of the array are omitted from the final result', ->
3535
values = [null, null, 3]
3636
expected = [3]
3737
expect(FlattenArray.flatten values).toEqual expected
3838

39-
xit 'consecutive null values in the middle of the list are omitted from the final result', ->
39+
xit 'consecutive null values in the middle of the array are omitted from the final result', ->
4040
values = [1, null, null, 4]
4141
expected = [1, 4]
4242
expect(FlattenArray.flatten values).toEqual expected
4343

44-
xit '6 level nest list with null values', ->
44+
xit '6 level nest array with null values', ->
4545
values = [0, 2, [[2, 3], 8, [[100]], null, [[null]]], -2]
4646
expected = [0, 2, 2, 3, 8, 100, -2]
4747
expect(FlattenArray.flatten values).toEqual expected
4848

49-
xit 'all values in nested list are null', ->
49+
xit 'all values in nested array are null', ->
5050
values = [null, [[[null]]], null, null, [[null, null], null], null]
5151
expected = []
5252
expect(FlattenArray.flatten values).toEqual expected

exercises/practice/largest-series-product/.meta/example.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class LargestSeriesProduct
33
if span < 0
44
throw new Error 'span must not be negative'
55
if span > digits.length
6-
throw new Error 'span must be smaller than string length'
6+
throw new Error 'span must not exceed string length'
77
if digits.match(/[^0-9]/)
88
throw new Error 'digits input must only contain digits'
99

exercises/practice/largest-series-product/.meta/tests.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ description = "reports zero if all spans include zero"
3838

3939
[5d81aaf7-4f67-4125-bf33-11493cc7eab7]
4040
description = "rejects span longer than string length"
41+
include = false
42+
43+
[0ae1ce53-d9ba-41bb-827f-2fceb64f058b]
44+
description = "rejects span longer than string length"
45+
reimplements = "5d81aaf7-4f67-4125-bf33-11493cc7eab7"
4146

4247
[06bc8b90-0c51-4c54-ac22-3ec3893a079e]
4348
description = "reports 1 for empty string and empty product (0 span)"
@@ -47,6 +52,11 @@ description = "reports 1 for nonempty string and empty product (0 span)"
4752

4853
[6d96c691-4374-4404-80ee-2ea8f3613dd4]
4954
description = "rejects empty string and nonzero span"
55+
include = false
56+
57+
[6cf66098-a6af-4223-aab1-26aeeefc7402]
58+
description = "rejects empty string and nonzero span"
59+
reimplements = "6d96c691-4374-4404-80ee-2ea8f3613dd4"
5060

5161
[7a38f2d6-3c35-45f6-8d6f-12e6e32d4d74]
5262
description = "rejects invalid character in digits"

exercises/practice/largest-series-product/largest-series-product.spec.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe 'Largest Series Product', ->
4040
xit 'rejects span longer than string length', ->
4141
expect ->
4242
Lsp.largestProduct '123', 4
43-
.toThrow new Error 'span must be smaller than string length'
43+
.toThrow new Error 'span must not exceed string length'
4444

4545
xit 'reports 1 for empty string and empty product (0 span)', ->
4646
result = Lsp.largestProduct '', 0
@@ -53,7 +53,7 @@ describe 'Largest Series Product', ->
5353
xit 'rejects empty string and nonzero span', ->
5454
expect ->
5555
Lsp.largestProduct '', 1
56-
.toThrow new Error 'span must be smaller than string length'
56+
.toThrow new Error 'span must not exceed string length'
5757

5858
xit 'rejects invalid character in digits', ->
5959
expect ->
Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Instructions
22

3-
Determine whether a credit card number is valid according to the [Luhn formula][luhn].
3+
Determine whether a number is valid according to the [Luhn formula][luhn].
44

55
The number will be provided as a string.
66

@@ -10,54 +10,59 @@ Strings of length 1 or less are not valid.
1010
Spaces are allowed in the input, but they should be stripped before checking.
1111
All other non-digit characters are disallowed.
1212

13-
### Example 1: valid credit card number
13+
## Examples
1414

15-
```text
16-
4539 3195 0343 6467
17-
```
15+
### Valid credit card number
1816

19-
The first step of the Luhn algorithm is to double every second digit, starting from the right.
20-
We will be doubling
17+
The number to be checked is `4539 3195 0343 6467`.
18+
19+
The first step of the Luhn algorithm is to start at the end of the number and double every second digit, beginning with the second digit from the right and moving left.
2120

2221
```text
2322
4539 3195 0343 6467
2423
↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ (double these)
2524
```
2625

27-
If doubling the number results in a number greater than 9 then subtract 9 from the product.
28-
The results of our doubling:
26+
If the result of doubling a digit is greater than 9, we subtract 9 from that result.
27+
We end up with:
2928

3029
```text
3130
8569 6195 0383 3437
3231
```
3332

34-
Then sum all of the digits:
33+
Finally, we sum all digits.
34+
If the sum is evenly divisible by 10, the original number is valid.
3535

3636
```text
37-
8+5+6+9+6+1+9+5+0+3+8+3+3+4+3+7 = 80
37+
8 + 5 + 6 + 9 + 6 + 1 + 9 + 5 + 0 + 3 + 8 + 3 + 3 + 4 + 3 + 7 = 80
3838
```
3939

40-
If the sum is evenly divisible by 10, then the number is valid.
41-
This number is valid!
40+
80 is evenly divisible by 10, so number `4539 3195 0343 6467` is valid!
41+
42+
### Invalid Canadian SIN
43+
44+
The number to be checked is `066 123 468`.
4245

43-
### Example 2: invalid credit card number
46+
We start at the end of the number and double every second digit, beginning with the second digit from the right and moving left.
4447

4548
```text
46-
8273 1232 7352 0569
49+
066 123 478
50+
↑ ↑ ↑ ↑ (double these)
4751
```
4852

49-
Double the second digits, starting from the right
53+
If the result of doubling a digit is greater than 9, we subtract 9 from that result.
54+
We end up with:
5055

5156
```text
52-
7253 2262 5312 0539
57+
036 226 458
5358
```
5459

55-
Sum the digits
60+
We sum the digits:
5661

5762
```text
58-
7+2+5+3+2+2+6+2+5+3+1+2+0+5+3+9 = 57
63+
0 + 3 + 6 + 2 + 2 + 6 + 4 + 5 + 8 = 36
5964
```
6065

61-
57 is not evenly divisible by 10, so this number is not valid.
66+
36 is not evenly divisible by 10, so number `066 123 478` is not valid!
6267

6368
[luhn]: https://en.wikipedia.org/wiki/Luhn_algorithm

0 commit comments

Comments
 (0)