-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync exercise files and metadata (#662)
- Loading branch information
Showing
80 changed files
with
510 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Instructions append | ||
|
||
You may (or may not!) want to call the function `permutations(a, t)` from [Combinatorics.jl](https://github.com/JuliaMath/Combinatorics.jl) in your solution. | ||
If you would like to use it, you can include the **read-only** file `permutations.jl` with `include("permutations.jl")`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
# Instructions | ||
|
||
An anagram is a rearrangement of letters to form a new word. | ||
Given a word and a list of candidates, select the sublist of anagrams of the given word. | ||
An anagram is a rearrangement of letters to form a new word: for example `"owns"` is an anagram of `"snow"`. | ||
A word is not its own anagram: for example, `"stop"` is not an anagram of `"stop"`. | ||
|
||
Given `"listen"` and a list of candidates like `"enlists" "google" | ||
"inlets" "banana"` the program should return a list containing | ||
`"inlets"`. | ||
Given a target word and a set of candidate words, this exercise requests the anagram set: the subset of the candidates that are anagrams of the target. | ||
|
||
The target and candidates are words of one or more ASCII alphabetic characters (`A`-`Z` and `a`-`z`). | ||
Lowercase and uppercase characters are equivalent: for example, `"PoTS"` is an anagram of `"sTOp"`, but `StoP` is not an anagram of `sTOp`. | ||
The anagram set is the subset of the candidate set that are anagrams of the target (in any order). | ||
Words in the anagram set should have the same letter case as in the candidate set. | ||
|
||
Given the target `"stone"` and candidates `"stone"`, `"tones"`, `"banana"`, `"tons"`, `"notes"`, `"Seton"`, the anagram set is `"tones"`, `"notes"`, `"Seton"`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
# Instructions | ||
|
||
Bob is a lackadaisical teenager. In conversation, his responses are very limited. | ||
Your task is to determine what Bob will reply to someone when they say something to him or ask him a question. | ||
|
||
Bob answers 'Sure.' if you ask him a question, such as "How are you?". | ||
Bob only ever answers one of five things: | ||
|
||
He answers 'Whoa, chill out!' if you YELL AT HIM (in all capitals). | ||
|
||
He answers 'Calm down, I know what I'm doing!' if you yell a question at him. | ||
|
||
He says 'Fine. Be that way!' if you address him without actually saying | ||
anything. | ||
|
||
He answers 'Whatever.' to anything else. | ||
|
||
Bob's conversational partner is a purist when it comes to written communication and always follows normal rules regarding sentence punctuation in English. | ||
- **"Sure."** | ||
This is his response if you ask him a question, such as "How are you?" | ||
The convention used for questions is that it ends with a question mark. | ||
- **"Whoa, chill out!"** | ||
This is his answer if you YELL AT HIM. | ||
The convention used for yelling is ALL CAPITAL LETTERS. | ||
- **"Calm down, I know what I'm doing!"** | ||
This is what he says if you yell a question at him. | ||
- **"Fine. Be that way!"** | ||
This is how he responds to silence. | ||
The convention used for silence is nothing, or various combinations of whitespace characters. | ||
- **"Whatever."** | ||
This is what he answers to anything else. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Introduction | ||
|
||
Bob is a [lackadaisical][] teenager. | ||
He likes to think that he's very cool. | ||
And he definitely doesn't get excited about things. | ||
That wouldn't be cool. | ||
|
||
When people talk to him, his responses are pretty limited. | ||
|
||
[lackadaisical]: https://www.collinsdictionary.com/dictionary/english/lackadaisical |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 54 additions & 47 deletions
101
exercises/practice/circular-buffer/.docs/instructions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,58 @@ | ||
# Instructions | ||
|
||
A circular buffer, cyclic buffer or ring buffer is a data structure that | ||
uses a single, fixed-size buffer as if it were connected end-to-end. | ||
|
||
A circular buffer first starts empty and of some predefined length. For | ||
example, this is a 7-element buffer: | ||
<!-- prettier-ignore --> | ||
[ ][ ][ ][ ][ ][ ][ ] | ||
|
||
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][ ][ ][ ] | ||
|
||
Then assume that two more elements are added — 2 & 3 — which get | ||
appended after the 1: | ||
<!-- prettier-ignore --> | ||
[ ][ ][ ][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][ ] | ||
A circular buffer, cyclic buffer or ring buffer is a data structure that uses a single, fixed-size buffer as if it were connected end-to-end. | ||
|
||
A circular buffer first starts empty and of some predefined length. | ||
For example, this is a 7-element buffer: | ||
|
||
```text | ||
[ ][ ][ ][ ][ ][ ][ ] | ||
``` | ||
|
||
Assume that a 1 is written into the middle of the buffer (exact starting location does not matter in a circular buffer): | ||
|
||
```text | ||
[ ][ ][ ][1][ ][ ][ ] | ||
``` | ||
|
||
Then assume that two more elements are added — 2 & 3 — which get appended after the 1: | ||
|
||
```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: | ||
|
||
```text | ||
[ ][ ][ ][ ][ ][3][ ] | ||
``` | ||
|
||
If the buffer has 7 elements then it is completely full: | ||
<!-- prettier-ignore --> | ||
[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] | ||
|
||
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] | ||
|
||
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 | ||
[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: | ||
|
||
```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: | ||
|
||
```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. | ||
|
||
```text | ||
[C][D][7][8][9][A][B] | ||
``` |
Oops, something went wrong.