Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync exercise docs #333

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion exercises/practice/accumulate/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
},
"blurb": "Implement the `accumulate` operation, which, given a collection and an operation to perform on each element of the collection, returns a new collection containing the result of applying that operation to each element of the input collection.",
"source": "Conversation with James Edward Gray II",
"source_url": "https://twitter.com/jeg2"
"source_url": "http://graysoftinc.com/"
}
10 changes: 5 additions & 5 deletions exercises/practice/acronym/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Punctuation is handled as follows: hyphens are word separators (like whitespace)

For example:

|Input|Output|
|-|-|
|As Soon As Possible|ASAP|
|Liquid-crystal display|LCD|
|Thank George It's Friday!|TGIF|
| Input | Output |
| ------------------------- | ------ |
| As Soon As Possible | ASAP |
| Liquid-crystal display | LCD |
| Thank George It's Friday! | TGIF |
4 changes: 2 additions & 2 deletions exercises/practice/affine-cipher/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The affine cipher is a type of monoalphabetic substitution cipher.
Each character is mapped to its numeric equivalent, encrypted with a mathematical function and then converted to the letter relating to its new numeric value.
Although all monoalphabetic ciphers are weak, the affine cipher is much stronger than the atbash cipher, because it has many more keys.

[//]: # ( monoalphabetic as spelled by Merriam-Webster, compare to polyalphabetic )
[//]: # " monoalphabetic as spelled by Merriam-Webster, compare to polyalphabetic "

## Encryption

Expand All @@ -23,7 +23,7 @@ Where:
For the Roman alphabet `m` is `26`.
- `a` and `b` are integers which make the encryption key

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]).
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]).
In case `a` is not coprime to `m`, your program should indicate that this is an error.
Otherwise it should encrypt or decrypt with the provided key.

Expand Down
8 changes: 4 additions & 4 deletions exercises/practice/all-your-base/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ Given a number in base **a**, represented as a sequence of digits, convert it to

In positional notation, a number in base **b** can be understood as a linear combination of powers of **b**.

The number 42, *in base 10*, means:
The number 42, _in base 10_, means:

`(4 * 10^1) + (2 * 10^0)`

The number 101010, *in base 2*, means:
The number 101010, _in base 2_, means:

`(1 * 2^5) + (0 * 2^4) + (1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (0 * 2^0)`

The number 1120, *in base 3*, means:
The number 1120, _in base 3_, means:

`(1 * 3^3) + (1 * 3^2) + (2 * 3^1) + (0 * 3^0)`

I think you got the idea!

*Yes. Those three numbers above are exactly the same. Congratulations!*
_Yes. Those three numbers above are exactly the same. Congratulations!_

[positional-notation]: https://en.wikipedia.org/wiki/Positional_notation
2 changes: 1 addition & 1 deletion exercises/practice/allergies/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ Now, given just that score of 34, your program should be able to say:
- Whether Tom is allergic to any one of those allergens listed above.
- All the allergens Tom is allergic to.

Note: a given score may include allergens **not** listed above (i.e. allergens that score 256, 512, 1024, etc.).
Note: a given score may include allergens **not** listed above (i.e. allergens that score 256, 512, 1024, etc.).
Your program should ignore those components of the score.
For example, if the allergy score is 257, your program should only report the eggs (1) allergy.
5 changes: 5 additions & 0 deletions exercises/practice/anagram/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ description = "detects anagrams using case-insensitive possible matches"

[7cc195ad-e3c7-44ee-9fd2-d3c344806a2c]
description = "does not detect an anagram if the original word is repeated"
include = false

[630abb71-a94e-4715-8395-179ec1df9f91]
glaxxie marked this conversation as resolved.
Show resolved Hide resolved
description = "does not detect an anagram if the original word is repeated"
reimplements = "7cc195ad-e3c7-44ee-9fd2-d3c344806a2c"

[9878a1c9-d6ea-4235-ae51-3ea2befd6842]
description = "anagrams must use all letters exactly once"
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/armstrong-numbers/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ An [Armstrong number][armstrong-number] is a number that is the sum of its own d
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.

Expand Down
3 changes: 1 addition & 2 deletions exercises/practice/binary-search-tree/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
]
},
"blurb": "Insert and search for numbers in a binary tree.",
"source": "Josh Cheek",
"source_url": "https://twitter.com/josh_cheek"
"source": "Josh Cheek"
}
2 changes: 1 addition & 1 deletion exercises/practice/binary-search/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Binary search only works when a list has been sorted.

The algorithm looks like this:

- Find the middle element of a *sorted* list and compare it with the item we're looking for.
- Find the middle element of a _sorted_ list and compare it with the item we're looking for.
- If the middle element is our item, then we're done!
- If the middle element is greater than our item, we can eliminate that element and all the elements **after** it.
- If the middle element is less than our item, we can eliminate that element and all the elements **before** it.
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/book-store/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Instructions

To try and encourage more sales of different books from a popular 5 books series, a bookshop has decided to offer discounts on multiple book purchases.
To try and encourage more sales of different books from a popular 5 book series, a bookshop has decided to offer discounts on multiple book purchases.

One copy of any of the five books costs $8.

Expand Down
48 changes: 32 additions & 16 deletions exercises/practice/circular-buffer/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,55 @@ A circular buffer, cyclic buffer or ring buffer is a data structure that uses a

A circular buffer first starts empty and of some predefined length.
For example, this is a 7-element buffer:
<!-- prettier-ignore -->
[ ][ ][ ][ ][ ][ ][ ]

```text
[ ][ ][ ][ ][ ][ ][ ]
```

Assume that a 1 is written into the middle of the buffer (exact starting location does not matter in a circular buffer):
<!-- prettier-ignore -->
[ ][ ][ ][1][ ][ ][ ]

```text
[ ][ ][ ][1][ ][ ][ ]
```

Then assume that two more elements are added — 2 & 3 — which get appended after the 1:
<!-- prettier-ignore -->
[ ][ ][ ][1][2][3][ ]

```text
[ ][ ][ ][1][2][3][ ]
```

If two elements are then removed from the buffer, the oldest values inside the buffer are removed.
The two elements removed, in this case, are 1 & 2, leaving the buffer with just a 3:
<!-- prettier-ignore -->
[ ][ ][ ][ ][ ][3][ ]

```text
[ ][ ][ ][ ][ ][3][ ]
```

If the buffer has 7 elements then it is completely full:
<!-- prettier-ignore -->
[5][6][7][8][9][3][4]

```text
[5][6][7][8][9][3][4]
```

When the buffer is full an error will be raised, alerting the client that further writes are blocked until a slot becomes free.

When the buffer is full, the client can opt to overwrite the oldest data with a forced write.
In this case, two more elements — A & B — are added and they overwrite the 3 & 4:
<!-- prettier-ignore -->
[5][6][7][8][9][A][B]

```text
[5][6][7][8][9][A][B]
```

3 & 4 have been replaced by A & B making 5 now the oldest data in the buffer.
Finally, if two elements are removed then what would be returned is 5 & 6 yielding the buffer:
<!-- prettier-ignore -->
[ ][ ][7][8][9][A][B]

```text
[ ][ ][7][8][9][A][B]
```

Because there is space available, if the client again uses overwrite to store C & D then the space where 5 & 6 were stored previously will be used not the location of 7 & 8.
7 is still the oldest element and the buffer is once again full.
<!-- prettier-ignore -->
[C][D][7][8][9][A][B]

```text
[C][D][7][8][9][A][B]
```
7 changes: 4 additions & 3 deletions exercises/practice/clock/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"authors": ["glaxxie"],
"authors": [
"glaxxie"
],
"files": {
"solution": [
"Clock.ps1"
Expand All @@ -12,6 +14,5 @@
]
},
"blurb": "Implement a clock that handles times without dates.",
"source": "Pairing session with Erin Drummond",
"source_url": "https://twitter.com/ebdrummond"
"source": "Pairing session with Erin Drummond"
}
3 changes: 3 additions & 0 deletions exercises/practice/custom-set/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ description = "Sets with the same elements are equal -> sets with different elem
[06059caf-9bf4-425e-aaff-88966cb3ea14]
description = "Sets with the same elements are equal -> set is not equal to larger set with same elements"

[d4a1142f-09aa-4df9-8b83-4437dcf7ec24]
description = "Sets with the same elements are equal -> set is equal to a set constructed from an array with duplicates"
glaxxie marked this conversation as resolved.
Show resolved Hide resolved

[8a677c3c-a658-4d39-bb88-5b5b1a9659f4]
description = "Unique elements can be added to a set -> add to empty set"

Expand Down
8 changes: 8 additions & 0 deletions exercises/practice/darts/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Write a function that returns the earned points in a single toss of a Darts game

In our particular instance of the game, the target rewards 4 different amounts of points, depending on where the dart lands:

![Our dart scoreboard with values from a complete miss to a bullseye](https://assets.exercism.org/images/exercises/darts/darts-scoreboard.svg)

- If the dart lands outside the target, player earns no points (0 points).
- If the dart lands in the outer circle of the target, player earns 1 point.
- If the dart lands in the middle circle of the target, player earns 5 points.
Expand All @@ -16,8 +18,14 @@ Of course, they are all centered at the same point — that is, the circles are

Write a function that given a point in the target (defined by its [Cartesian coordinates][cartesian-coordinates] `x` and `y`, where `x` and `y` are [real][real-numbers]), returns the correct amount earned by a dart landing at that point.

## Credit

The scoreboard image was created by [habere-et-dispertire][habere-et-dispertire] using [Inkscape][inkscape].

[darts]: https://en.wikipedia.org/wiki/Darts
[darts-target]: https://en.wikipedia.org/wiki/Darts#/media/File:Darts_in_a_dartboard.jpg
[concentric]: https://mathworld.wolfram.com/ConcentricCircles.html
[cartesian-coordinates]: https://www.mathsisfun.com/data/cartesian-coordinates.html
[real-numbers]: https://www.mathsisfun.com/numbers/real-numbers.html
[habere-et-dispertire]: https://exercism.org/profiles/habere-et-dispertire
[inkscape]: https://en.wikipedia.org/wiki/Inkscape
5 changes: 5 additions & 0 deletions exercises/practice/dnd-character/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ description = "random character is valid"

[2ca77b9b-c099-46c3-a02c-0d0f68ffa0fe]
description = "each ability is only calculated once"
include = false

[dca2b2ec-f729-4551-84b9-078876bb4808]
glaxxie marked this conversation as resolved.
Show resolved Hide resolved
description = "each ability is only calculated once"
reimplements = "2ca77b9b-c099-46c3-a02c-0d0f68ffa0fe"
2 changes: 1 addition & 1 deletion exercises/practice/error-handling/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Implement various kinds of error handling and resource management.
An important point of programming is how to handle errors and close resources even if errors occur.

This exercise requires you to handle various errors.
Because error handling is rather programming language specific you'll have to refer to the tests for your track to see what's exactly required.
Because error handling is rather programming language specific you'll have to refer to the tests for your track to see what's exactly required.
12 changes: 9 additions & 3 deletions exercises/practice/grains/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ description = "returns the number of grains on the square -> grains on square 16
[acd81b46-c2ad-4951-b848-80d15ed5a04f]
description = "returns the number of grains on the square -> grains on square 32"

[c73b470a-5efb-4d53-9ac6-c5f6487f227b]
description = "returns the number of grains on the square -> grains on square 64"

[1d47d832-3e85-4974-9466-5bd35af484e3]
description = "returns the number of grains on the square -> square 0 raises an exception"
description = "returns the number of grains on the square -> square 0 is invalid"

[61974483-eeb2-465e-be54-ca5dde366453]
description = "returns the number of grains on the square -> negative square raises an exception"
description = "returns the number of grains on the square -> negative square is invalid"

[a95e4374-f32c-45a7-a10d-ffec475c012f]
description = "returns the number of grains on the square -> square greater than 64 raises an exception"
description = "returns the number of grains on the square -> square greater than 64 is invalid"

[6eb07385-3659-4b45-a6be-9dc474222750]
description = "returns the total number of grains on the board"
glaxxie marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion exercises/practice/hello-world/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
".meta/HelloWorld.example.ps1"
]
},
"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": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program"
}
3 changes: 3 additions & 0 deletions exercises/practice/isbn-verifier/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.

[0caa3eac-d2e3-4c29-8df8-b188bc8c9292]
description = "valid isbn"
glaxxie marked this conversation as resolved.
Show resolved Hide resolved

[19f76b53-7c24-45f8-87b8-4604d0ccd248]
description = "invalid isbn check digit"

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/isogram/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Examples of isograms:
- downstream
- six-year-old

The word *isograms*, however, is not an isogram, because the s repeats.
The word _isograms_, however, is not an isogram, because the s repeats.
3 changes: 3 additions & 0 deletions exercises/practice/isogram/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ description = "duplicated character in the middle"

[310ac53d-8932-47bc-bbb4-b2b94f25a83e]
description = "same first and last characters"

[0d0b8644-0a1e-4a31-a432-2b3ee270d847]
description = "word with duplicated character and with two hyphens"
5 changes: 5 additions & 0 deletions exercises/practice/knapsack/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 1 addition & 20 deletions exercises/practice/leap/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
# Instructions

Given a year, report if it is a leap year.

The tricky thing here is that a leap year in the Gregorian calendar occurs:

```text
on every year that is evenly divisible by 4
except every year that is evenly divisible by 100
unless the year is also evenly divisible by 400
```

For example, 1997 is not a leap year, but 1996 is.
1900 is not a leap year, but 2000 is.

## Notes

Though our exercise adopts some very simple rules, there is more to learn!

For a delightful, four minute explanation of the whole leap year phenomenon, go watch [this youtube video][video].

[video]: https://www.youtube.com/watch?v=xX96xng7sAE
Your task is to determine whether a given year is a leap year.
16 changes: 16 additions & 0 deletions exercises/practice/leap/.docs/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Introduction

A leap year (in the Gregorian calendar) occurs:

- In every year that is evenly divisible by 4
- Unless the year is evenly divisible by 100, in which case it's only a leap year if the year is also evenly divisible by 400.

Some examples:

- 1997 was not a leap year as it's not divisible by 4.
- 1900 was not a leap year as it's not divisible by 400
- 2000 was a leap year!

~~~~exercism/note
For a delightful, four minute explanation of the whole phenomenon of leap years, check out [this youtube video](https://www.youtube.com/watch?v=xX96xng7sAE).
~~~~
2 changes: 1 addition & 1 deletion exercises/practice/leap/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
".meta/LeapYear.example.ps1"
]
},
"blurb": "Given a year, report if it is a leap year.",
"blurb": "Determine whether a given year is a leap year.",
"source": "CodeRanch Cattle Drive, Assignment 3",
"source_url": "https://coderanch.com/t/718816/Leap"
}
16 changes: 8 additions & 8 deletions exercises/practice/list-ops/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ Implement a series of basic list operations, without using existing functions.

The precise number and names of the operations to be implemented will be track dependent to avoid conflicts with existing names, but the general operations you will implement include:

- `append` (*given two lists, add all items in the second list to the end of the first list*);
- `concatenate` (*given a series of lists, combine all items in all lists into one flattened list*);
- `filter` (*given a predicate and a list, return the list of all items for which `predicate(item)` is True*);
- `length` (*given a list, return the total number of items within it*);
- `map` (*given a function and a list, return the list of the results of applying `function(item)` on all items*);
- `foldl` (*given a function, a list, and initial accumulator, fold (reduce) each item into the accumulator from the left*);
- `foldr` (*given a function, a list, and an initial accumulator, fold (reduce) each item into the accumulator from the right*);
- `reverse` (*given a list, return a list with all the original items, but in reversed order*).
- `append` (_given two lists, add all items in the second list to the end of the first list_);
- `concatenate` (_given a series of lists, combine all items in all lists into one flattened list_);
- `filter` (_given a predicate and a list, return the list of all items for which `predicate(item)` is True_);
- `length` (_given a list, return the total number of items within it_);
- `map` (_given a function and a list, return the list of the results of applying `function(item)` on all items_);
- `foldl` (_given a function, a list, and initial accumulator, fold (reduce) each item into the accumulator from the left_);
- `foldr` (_given a function, a list, and an initial accumulator, fold (reduce) each item into the accumulator from the right_);
- `reverse` (_given a list, return a list with all the original items, but in reversed order_).

Note, the ordering in which arguments are passed to the fold functions (`foldl`, `foldr`) is significant.
Loading