Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions exercises/practice/binary-search-tree/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,52 @@ All data in the left subtree is less than or equal to the current node's data, a

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

![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)

```text
4
/
2
```

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

![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)

```text
4
/ \
2 6
```

If we then added 3, it would look like this

![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)

```text
4
/ \
2 6
\
3
```

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

![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)

```text
4
/ \
/ \
2 6
/ \ / \
1 3 5 7
```

## Credit

The images were created by [habere-et-dispertire][habere-et-dispertire] using [PGF/TikZ][pgf-tikz] by Till Tantau.

[habere-et-dispertire]: https://exercism.org/profiles/habere-et-dispertire
[pgf-tikz]: https://en.wikipedia.org/wiki/PGF/TikZ
5 changes: 5 additions & 0 deletions exercises/practice/bob/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
2 changes: 1 addition & 1 deletion exercises/practice/bob/BobResponse.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Describe "Test Get-BobResponse" {
}

It "multiple line question" {
Get-BobResponse -HeyBob "`nDoes this cryogenic chamber make me look fat?`nno" | Should -BeExactly "Whatever."
Get-BobResponse -HeyBob "`nDoes this cryogenic chamber make`n me look fat?" | Should -BeExactly "Sure."
}

It "starting with whitespace" {
Expand Down
5 changes: 5 additions & 0 deletions exercises/practice/crypto-square/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,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"
2 changes: 1 addition & 1 deletion exercises/practice/crypto-square/CryptoSquare.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Describe "CryptoSquare test cases" {
$got | Should -BeExactly $want
}

It "54 character plaintext results in 7 chunks, the last two with trailing spaces" {
It "54 character plaintext results in 8 chunks, the last two with trailing spaces" {
$got = Invoke-CryptoSquare -PlainText "If man was meant to stay on the ground, god would have given us roots."
$want = "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau "

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/dot-dsl/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Write a Domain Specific Language similar to the Graphviz dot language.
Our DSL is similar to the Graphviz dot language in that our DSL will be used to create graph data structures.
However, unlike the DOT Language, our DSL will be an internal DSL for use only in our language.

More information about the difference between internal and external DSLs can be found [here][fowler-dsl].
[Learn more about the difference between internal and external DSLs][fowler-dsl].

[dsl]: https://en.wikipedia.org/wiki/Domain-specific_language
[dot-language]: https://en.wikipedia.org/wiki/DOT_(graph_description_language)
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/eliuds-eggs/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The position information encoding is calculated as follows:

### Decimal number on the display

16
8

### Actual eggs in the coop

Expand Down
20 changes: 20 additions & 0 deletions exercises/practice/flatten-array/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,32 @@ description = "null values are omitted from the final result"

[c6cf26de-8ccd-4410-84bd-b9efd88fd2bc]
description = "consecutive null values at the front of the list are omitted from the final result"
include = false

[bc72da10-5f55-4ada-baf3-50e4da02ec8e]
description = "consecutive null values at the front of the array are omitted from the final result"
reimplements = "c6cf26de-8ccd-4410-84bd-b9efd88fd2bc"

[382c5242-587e-4577-b8ce-a5fb51e385a1]
description = "consecutive null values in the middle of the list are omitted from the final result"
include = false

[6991836d-0d9b-4703-80a0-3f1f23eb5981]
description = "consecutive null values in the middle of the array are omitted from the final result"
reimplements = "382c5242-587e-4577-b8ce-a5fb51e385a1"

[ef1d4790-1b1e-4939-a179-51ace0829dbd]
description = "6 level nest list with null values"
include = false

[dc90a09c-5376-449c-a7b3-c2d20d540069]
description = "6 level nested array with null values"
reimplements = "ef1d4790-1b1e-4939-a179-51ace0829dbd"

[85721643-705a-4150-93ab-7ae398e2942d]
description = "all values in nested list are null"
include = false

[51f5d9af-8f7f-4fb5-a156-69e8282cb275]
description = "all values in nested array are null"
reimplements = "85721643-705a-4150-93ab-7ae398e2942d"
8 changes: 4 additions & 4 deletions exercises/practice/flatten-array/FlattenArray.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,28 @@ Describe "flatten array test cases" {
$got | Should -BeExactly $want
}

It "consecutive null values at the front of the list are omitted from the final result" {
It "consecutive null values at the front of the array are omitted from the final result" {
$got = Invoke-FlattenArray -Array @($null, $null, 5)
$want = @(5)

$got | Should -BeExactly $want
}

It "consecutive null values in the middle of the list are omitted from the final result" {
It "consecutive null values in the middle of the array are omitted from the final result" {
$got = Invoke-FlattenArray -Array @(1, $null, $null, 4)
$want = @(1, 4)

$got | Should -BeExactly $want
}

It "6 level nest list with null values" {
It "6 level nest array with null values" {
$got = Invoke-FlattenArray -Array @(0, 2, @(@(2, 3), 8, @(@(100)), $null, @(@($null))), -2)
$want = @(0, 2, 2, 3, 8, 100, -2)

$got | Should -BeExactly $want
}

It "all values in nested list are null" {
It "all values in nested array are null" {
$got = Invoke-FlattenArray -Array @($null, @(@(@($null))), $null, $null, @(@($null, $null), $null), $null)
$want = @()

Expand Down
18 changes: 18 additions & 0 deletions exercises/practice/forth/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ description = "addition -> errors if there is nothing on the stack"
[06efb9a4-817a-435e-b509-06166993c1b8]
description = "addition -> errors if there is only one value on the stack"

[1e07a098-c5fa-4c66-97b2-3c81205dbc2f]
description = "addition -> more than two values on the stack"

[09687c99-7bbc-44af-8526-e402f997ccbf]
description = "subtraction -> can subtract two numbers"

Expand All @@ -33,6 +36,9 @@ description = "subtraction -> errors if there is nothing on the stack"
[b3cee1b2-9159-418a-b00d-a1bb3765c23b]
description = "subtraction -> errors if there is only one value on the stack"

[2c8cc5ed-da97-4cb1-8b98-fa7b526644f4]
description = "subtraction -> more than two values on the stack"

[5df0ceb5-922e-401f-974d-8287427dbf21]
description = "multiplication -> can multiply two numbers"

Expand All @@ -42,6 +48,9 @@ description = "multiplication -> errors if there is nothing on the stack"
[8ba4b432-9f94-41e0-8fae-3b3712bd51b3]
description = "multiplication -> errors if there is only one value on the stack"

[5cd085b5-deb1-43cc-9c17-6b1c38bc9970]
description = "multiplication -> more than two values on the stack"

[e74c2204-b057-4cff-9aa9-31c7c97a93f5]
description = "division -> can divide two numbers"

Expand All @@ -57,12 +66,21 @@ description = "division -> errors if there is nothing on the stack"
[d5547f43-c2ff-4d5c-9cb0-2a4f6684c20d]
description = "division -> errors if there is only one value on the stack"

[f224f3e0-b6b6-4864-81de-9769ecefa03f]
description = "division -> more than two values on the stack"

[ee28d729-6692-4a30-b9be-0d830c52a68c]
description = "combined arithmetic -> addition and subtraction"

[40b197da-fa4b-4aca-a50b-f000d19422c1]
description = "combined arithmetic -> multiplication and division"

[f749b540-53aa-458e-87ec-a70797eddbcb]
description = "combined arithmetic -> multiplication and addition"

[c8e5a4c2-f9bf-4805-9a35-3c3314e4989a]
description = "combined arithmetic -> addition and multiplication"

[c5758235-6eef-4bf6-ab62-c878e50b9957]
description = "dup -> copies a value on the stack"

Expand Down
30 changes: 30 additions & 0 deletions exercises/practice/forth/Forth.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Describe "Forth test cases" {
It "addition -> errors if there is only one value on the stack" {
{$forth.Evaluate(@("1 +"))} | Should -Throw "*Not enough items in stack to perform operation*"
}

It "addition -> more than two values on the stack" {
$forth.Evaluate(@("1 2 3 +"))
$forth.GetStack() | Should -Be @(1, 5)
}

It "subtraction -> can subtract two numbers" {
$forth.Evaluate(@("3 4 -"))
Expand All @@ -45,6 +50,11 @@ Describe "Forth test cases" {
It "subtraction -> errors if there is only one value on the stack" {
{$forth.Evaluate(@("1 -"))} | Should -Throw "*Not enough items in stack to perform operation*"
}

It "subtraction -> more than two values on the stack" {
$forth.Evaluate(@("1 12 3 -"))
$forth.GetStack() | Should -Be @(1, 9)
}

It "multiplication -> can multiply two numbers" {
$forth.Evaluate(@("2 4 *"))
Expand All @@ -58,6 +68,11 @@ Describe "Forth test cases" {
It "multiplication -> errors if there is only one value on the stack" {
{$forth.Evaluate(@("1 *"))} | Should -Throw "*Not enough items in stack to perform operation*"
}

It "multiplication -> more than two values on the stack" {
$forth.Evaluate(@("1 2 3 *"))
$forth.GetStack() | Should -Be @(1, 6)
}

It "division -> can divide two numbers" {
$forth.Evaluate(@("12 3 /"))
Expand All @@ -76,6 +91,11 @@ Describe "Forth test cases" {
It "division -> errors if there is nothing on the stack" {
{$forth.Evaluate(@("/"))} | Should -Throw "*Stack is empty*"
}

It "division -> more than two values on the stack" {
$forth.Evaluate(@("1 12 3 /"))
$forth.GetStack() | Should -Be @(1, 4)
}

It "division -> errors if there is only one value on the stack" {
{$forth.Evaluate(@("1 /"))} | Should -Throw "*Not enough items in stack to perform operation*"
Expand All @@ -90,6 +110,16 @@ Describe "Forth test cases" {
$forth.Evaluate(@("2 4 * 3 /"))
$forth.GetStack() | Should -Be @(2)
}

It "combined arithmetic -> multiplication and addition" {
$forth.Evaluate(@("1 3 4 * +"))
$forth.GetStack() | Should -Be @(13)
}

It "combined arithmetic -> addition and multiplication" {
$forth.Evaluate(@("1 3 4 + *"))
$forth.GetStack() | Should -Be @(7)
}
}

Context "stack manipulation operations" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Function Validator() {
Throw "digits input must only contain digits"
}
if ($Span -gt $Digits.Length) {
Throw "span must be smaller than string length"
Throw "span must not exceed string length"
}
if ($Span -lt 0) {
Throw "span must not be negative"
Expand Down
10 changes: 10 additions & 0 deletions exercises/practice/largest-series-product/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ 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)"
Expand All @@ -47,6 +52,11 @@ 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ Describe "Test LargestSeriesProduct Cases" {

Context "Invalid Inputs" {
It "rejects span longer than string length" {
{ Get-LargestSeriesProduct -Digits "123" -Span 4 } | Should -Throw "*span must be smaller than string length*"
{ Get-LargestSeriesProduct -Digits "123" -Span 4 } | Should -Throw "*span must not exceed string length*"
}

It "rejects empty string and nonzero span" {
{ Get-LargestSeriesProduct -Digits "" -Span 2 } | Should -Throw "*span must be smaller than string length*"
{ Get-LargestSeriesProduct -Digits "" -Span 2 } | Should -Throw "*span must not exceed string length*"
}

It "rejects invalid character in digits" {
Expand Down
Loading