Skip to content

Commit 9637c54

Browse files
authored
Sync upstream problem-specifications changes (#2404)
* Sync docs * Add missing invalidators * Update flatten-array tests [no important files changed]
1 parent 8223bbe commit 9637c54

File tree

12 files changed

+132
-28
lines changed

12 files changed

+132
-28
lines changed

exercises/practice/affine-cipher/.docs/instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Where:
2020

2121
- `i` is the letter's index from `0` to the length of the alphabet - 1.
2222
- `m` is the length of the alphabet.
23-
For the Roman alphabet `m` is `26`.
23+
For the Latin alphabet `m` is `26`.
2424
- `a` and `b` are integers which make up the encryption key.
2525

2626
Values `a` and `m` must be _coprime_ (or, _relatively prime_) for automatic decryption to succeed, i.e., they have number `1` as their only common factor (more information can be found in the [Wikipedia article about coprime integers][coprime-integers]).

exercises/practice/bottle-song/.meta/config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
],
1313
"example": [
1414
".meta/Example.cs"
15+
],
16+
"invalidator": [
17+
"BottleSong.csproj"
1518
]
1619
},
1720
"blurb": "Produce the lyrics to the popular children's repetitive song: Ten Green Bottles.",
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/FlattenArrayTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,31 @@ public void Null_values_are_omitted_from_the_final_result()
5656
}
5757

5858
[Fact(Skip = "Remove this Skip property to run this test")]
59-
public void Consecutive_null_values_at_the_front_of_the_list_are_omitted_from_the_final_result()
59+
public void Consecutive_null_values_at_the_front_of_the_array_are_omitted_from_the_final_result()
6060
{
6161
object?[] array = new object?[] { null, null, 3 };
6262
object?[] expected = [3];
6363
Assert.Equal(expected, FlattenArray.Flatten(array));
6464
}
6565

6666
[Fact(Skip = "Remove this Skip property to run this test")]
67-
public void Consecutive_null_values_in_the_middle_of_the_list_are_omitted_from_the_final_result()
67+
public void Consecutive_null_values_in_the_middle_of_the_array_are_omitted_from_the_final_result()
6868
{
6969
object?[] array = new object?[] { 1, null, null, 4 };
7070
object?[] expected = [1, 4];
7171
Assert.Equal(expected, FlattenArray.Flatten(array));
7272
}
7373

7474
[Fact(Skip = "Remove this Skip property to run this test")]
75-
public void Six_level_nest_list_with_null_values()
75+
public void Six_level_nested_array_with_null_values()
7676
{
7777
object?[] array = new object?[] { 0, 2, new object?[] { new object?[] { 2, 3 }, 8, new object?[] { new object?[] { 100 } }, null, new object?[] { new object?[] { null } } }, -2 };
7878
object?[] expected = [0, 2, 2, 3, 8, 100, -2];
7979
Assert.Equal(expected, FlattenArray.Flatten(array));
8080
}
8181

8282
[Fact(Skip = "Remove this Skip property to run this test")]
83-
public void All_values_in_nested_list_are_null()
83+
public void All_values_in_nested_array_are_null()
8484
{
8585
object?[] array = new object?[] { null, new object?[] { new object?[] { new object?[] { null } } }, null, null, new object?[] { new object?[] { null, null }, null }, null };
8686
object?[] expected = [];

exercises/practice/killer-sudoku-helper/.meta/config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
],
1212
"example": [
1313
".meta/Example.cs"
14+
],
15+
"invalidator": [
16+
"KillerSudokuHelper.csproj"
1417
]
1518
},
1619
"blurb": "Write a tool that makes it easier to solve Killer Sudokus",

exercises/practice/saddle-points/.docs/instructions.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ Or it might have one, or even several.
1313
Here is a grid that has exactly one candidate tree.
1414

1515
```text
16-
1 2 3 4
17-
|-----------
18-
1 | 9 8 7 8
19-
2 | 5 3 2 4 <--- potential tree house at row 2, column 1, for tree with height 5
20-
3 | 6 6 7 1
16+
17+
1 2 3 4
18+
|-----------
19+
1 | 9 8 7 8
20+
→ 2 |[5] 3 2 4
21+
3 | 6 6 7 1
2122
```
2223

2324
- Row 2 has values 5, 3, 2, and 4. The largest value is 5.

exercises/practice/satellite/.meta/config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
],
1212
"example": [
1313
".meta/Example.cs"
14+
],
15+
"invalidator": [
16+
"Satellite.csproj"
1417
]
1518
},
1619
"blurb": "Rebuild binary trees from pre-order and in-order traversals."

exercises/practice/sieve/.docs/instructions.md

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,96 @@ A prime number is a number larger than 1 that is only divisible by 1 and itself.
66
For example, 2, 3, 5, 7, 11, and 13 are prime numbers.
77
By contrast, 6 is _not_ a prime number as it not only divisible by 1 and itself, but also by 2 and 3.
88

9-
To use the Sieve of Eratosthenes, you first create a list of all the numbers between 2 and your given number.
10-
Then you repeat the following steps:
9+
To use the Sieve of Eratosthenes, first, write out all the numbers from 2 up to and including your given number.
10+
Then, follow these steps:
1111

12-
1. Find the next unmarked number in your list (skipping over marked numbers).
12+
1. Find the next unmarked number (skipping over marked numbers).
1313
This is a prime number.
1414
2. Mark all the multiples of that prime number as **not** prime.
1515

16-
You keep repeating these steps until you've gone through every number in your list.
16+
Repeat the steps until you've gone through every number.
1717
At the end, all the unmarked numbers are prime.
1818

1919
~~~~exercism/note
20-
The tests don't check that you've implemented the algorithm, only that you've come up with the correct list of primes.
21-
To check you are implementing the Sieve correctly, a good first test is to check that you do not use division or remainder operations.
20+
The Sieve of Eratosthenes marks off multiples of each prime using addition (repeatedly adding the prime) or multiplication (directly computing its multiples), rather than checking each number for divisibility.
21+
22+
The tests don't check that you've implemented the algorithm, only that you've come up with the correct primes.
2223
~~~~
2324

2425
## Example
2526

2627
Let's say you're finding the primes less than or equal to 10.
2728

28-
- List out 2, 3, 4, 5, 6, 7, 8, 9, 10, leaving them all unmarked.
29+
- Write out 2, 3, 4, 5, 6, 7, 8, 9, 10, leaving them all unmarked.
30+
31+
```text
32+
2 3 4 5 6 7 8 9 10
33+
```
34+
2935
- 2 is unmarked and is therefore a prime.
3036
Mark 4, 6, 8 and 10 as "not prime".
37+
38+
```text
39+
2 3 [4] 5 [6] 7 [8] 9 [10]
40+
41+
```
42+
3143
- 3 is unmarked and is therefore a prime.
3244
Mark 6 and 9 as not prime _(marking 6 is optional - as it's already been marked)_.
45+
46+
```text
47+
2 3 [4] 5 [6] 7 [8] [9] [10]
48+
49+
```
50+
3351
- 4 is marked as "not prime", so we skip over it.
52+
53+
```text
54+
2 3 [4] 5 [6] 7 [8] [9] [10]
55+
56+
```
57+
3458
- 5 is unmarked and is therefore a prime.
3559
Mark 10 as not prime _(optional - as it's already been marked)_.
60+
61+
```text
62+
2 3 [4] 5 [6] 7 [8] [9] [10]
63+
64+
```
65+
3666
- 6 is marked as "not prime", so we skip over it.
67+
68+
```text
69+
2 3 [4] 5 [6] 7 [8] [9] [10]
70+
71+
```
72+
3773
- 7 is unmarked and is therefore a prime.
74+
75+
```text
76+
2 3 [4] 5 [6] 7 [8] [9] [10]
77+
78+
```
79+
3880
- 8 is marked as "not prime", so we skip over it.
81+
82+
```text
83+
2 3 [4] 5 [6] 7 [8] [9] [10]
84+
85+
```
86+
3987
- 9 is marked as "not prime", so we skip over it.
88+
89+
```text
90+
2 3 [4] 5 [6] 7 [8] [9] [10]
91+
92+
```
93+
4094
- 10 is marked as "not prime", so we stop as there are no more numbers to check.
4195

42-
You've examined all numbers and found 2, 3, 5, and 7 are still unmarked, which means they're the primes less than or equal to 10.
96+
```text
97+
2 3 [4] 5 [6] 7 [8] [9] [10]
98+
99+
```
100+
101+
You've examined all the numbers and found that 2, 3, 5, and 7 are still unmarked, meaning they're the primes less than or equal to 10.

0 commit comments

Comments
 (0)