Skip to content
Open
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Your job is to help implement

A parity bit is simple way of detecting transmission errors.
The transmitters and receivers can only transmit and receive _exactly_ eight bits at a time (including the parity bit).
The parity bit is set so that there is an _even_ number 1s in each transmission and is always the first bit from the right.
The parity bit is set so that there is an _even_ number of 1 bits in each transmission, and the parity bit is always the first bit from the right.
So if the receiver receives `11000001`, `01110101` or `01000000` (i.e. a transmission with an odd number of 1 bits), it knows there is an error.

However, messages are rarely this short, and need to be transmitted in a sequence when they are longer.
Expand Down Expand Up @@ -40,7 +40,7 @@ Their parity bits are set to 1 so that they have an even number of 1 bits in the
They are transmitted as `01110001` and `00011011` (or `71` and `1B` in hex).

The last transmission (`1110`) has only four bits of data.
Since exactly eight bits are transmitted at a time and the parity bit is the right most bit, three 0 bits and then the parity bit are added to make up eight bits.
Since exactly eight bits are transmitted at a time and the parity bit is the rightmost bit, three 0 bits and then the parity bit are added to make up eight bits.
It now looks like this (where `_` is the parity bit):

```text
Expand Down
45 changes: 25 additions & 20 deletions exercises/practice/luhn/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Instructions

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

The number will be provided as a string.

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

### Example 1: valid credit card number
## Examples

```text
4539 3195 0343 6467
```
### Valid credit card number

The first step of the Luhn algorithm is to double every second digit, starting from the right.
We will be doubling
The number to be checked is `4539 3195 0343 6467`.

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.

```text
4539 3195 0343 6467
↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ (double these)
```

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

```text
8569 6195 0383 3437
```

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

```text
8+5+6+9+6+1+9+5+0+3+8+3+3+4+3+7 = 80
8 + 5 + 6 + 9 + 6 + 1 + 9 + 5 + 0 + 3 + 8 + 3 + 3 + 4 + 3 + 7 = 80
```

If the sum is evenly divisible by 10, then the number is valid.
This number is valid!
80 is evenly divisible by 10, so number `4539 3195 0343 6467` is valid!

### Invalid Canadian SIN

The number to be checked is `066 123 478`.

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

```text
8273 1232 7352 0569
066 123 478
↑ ↑ ↑ ↑ (double these)
```

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

```text
7253 2262 5312 0539
036 226 458
```

Sum the digits
We sum the digits:

```text
7+2+5+3+2+2+6+2+5+3+1+2+0+5+3+9 = 57
0 + 3 + 6 + 2 + 2 + 6 + 4 + 5 + 8 = 36
```

57 is not evenly divisible by 10, so this number is not valid.
36 is not evenly divisible by 10, so number `066 123 478` is not valid!

[luhn]: https://en.wikipedia.org/wiki/Luhn_algorithm
4 changes: 2 additions & 2 deletions exercises/practice/luhn/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

At the Global Verification Authority, you've just been entrusted with a critical assignment.
Across the city, from online purchases to secure logins, countless operations rely on the accuracy of numerical identifiers like credit card numbers, bank account numbers, transaction codes, and tracking IDs.
The Luhn algorithm is a simple checksum formula used to ensure these numbers are valid and error-free.
The Luhn algorithm is a simple checksum formula used to help identify mistyped numbers.

A batch of identifiers has just arrived on your desk.
All of them must pass the Luhn test to ensure they're legitimate.
If any fail, they'll be flagged as invalid, preventing errors or fraud, such as incorrect transactions or unauthorized access.
If any fail, they'll be flagged as invalid, preventing mistakes such as incorrect transactions or failed account verifications.

Can you ensure this is done right? The integrity of many services depends on you.
2 changes: 1 addition & 1 deletion exercises/practice/meetup/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Your task is to find the exact date of a meetup, given a month, year, weekday and week.

There are five week values to consider: `first`, `second`, `third`, `fourth`, `last`, `teenth`.
There are six week values to consider: `first`, `second`, `third`, `fourth`, `last`, `teenth`.

For example, you might be asked to find the date for the meetup on the first Monday in January 2018 (January 1, 2018).

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/phone-number/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Instructions

Clean up user-entered phone numbers so that they can be sent SMS messages.
Clean up phone numbers so that they can be sent SMS messages.

The **North American Numbering Plan (NANP)** is a telephone numbering system used by many countries in North America like the United States, Canada or Bermuda.
All NANP-countries share the same international country code: `1`.
Expand Down
47 changes: 20 additions & 27 deletions exercises/practice/protein-translation/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
# Instructions

Translate RNA sequences into proteins.
Your job is to translate RNA sequences into proteins.

RNA can be broken into three-nucleotide sequences called codons, and then translated to a protein like so:
RNA strands are made up of three-nucleotide sequences called **codons**.
Each codon translates to an **amino acid**.
When joined together, those amino acids make a protein.

RNA: `"AUGUUUUCU"` => translates to

Codons: `"AUG", "UUU", "UCU"`
=> which become a protein with the following sequence =>

Protein: `"Methionine", "Phenylalanine", "Serine"`

There are 64 codons which in turn correspond to 20 amino acids; however, all of the codon sequences and resulting amino acids are not important in this exercise.
If it works for one codon, the program should work for all of them.
However, feel free to expand the list in the test suite to include them all.

There are also three terminating codons (also known as 'STOP' codons); if any of these codons are encountered (by the ribosome), all translation ends and the protein is terminated.

All subsequent codons after are ignored, like this:

RNA: `"AUGUUUUCUUAAAUG"` =>

Codons: `"AUG", "UUU", "UCU", "UAA", "AUG"` =>

Protein: `"Methionine", "Phenylalanine", "Serine"`

Note the stop codon `"UAA"` terminates the translation and the final methionine is not translated into the protein sequence.

Below are the codons and resulting amino acids needed for the exercise.
In the real world, there are 64 codons, which in turn correspond to 20 amino acids.
However, for this exercise, you’ll only use a few of the possible 64.
They are listed below:

| Codon | Amino Acid |
| :----------------- | :------------ |
| ------------------ | ------------- |
| AUG | Methionine |
| UUU, UUC | Phenylalanine |
| UUA, UUG | Leucine |
Expand All @@ -40,6 +21,18 @@ Below are the codons and resulting amino acids needed for the exercise.
| UGG | Tryptophan |
| UAA, UAG, UGA | STOP |

For example, the RNA string β€œAUGUUUUCU” has three codons: β€œAUG”, β€œUUU” and β€œUCU”.
These map to Methionine, Phenylalanine, and Serine.

## β€œSTOP” Codons

You’ll note from the table above that there are three **β€œSTOP” codons**.
If you encounter any of these codons, ignore the rest of the sequence β€” the protein is complete.

For example, β€œAUGUUUUCUUAAAUG” contains a STOP codon (β€œUAA”).
Once we reach that point, we stop processing.
We therefore only consider the part before it (i.e. β€œAUGUUUUCU”), not any further codons after it (i.e. β€œAUG”).

Learn more about [protein translation on Wikipedia][protein-translation].

[protein-translation]: https://en.wikipedia.org/wiki/Translation_(biology)
24 changes: 12 additions & 12 deletions exercises/practice/relative-distance/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Instructions

Your task is to determine the degree of separation between two individuals in a family tree.
This is similar to the pop culture idea that every Hollywood actor is [within six degrees of Kevin Bacon][six-bacons].

- You will be given an input, with all parent names and their children.
- Each name is unique, a child _can_ have one or two parents.
Expand All @@ -13,22 +14,21 @@ Your task is to determine the degree of separation between two individuals in a
Given the following family tree:

```text
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Helena β”‚ β”‚ ErdΕ‘s β”‚ β”‚ Shusaku β”‚
β””β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”˜ └───────┐ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
β–Ό β–Ό β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Isla β”‚ β”‚ Tariq β”‚ β”‚ Kevin β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β–Ό β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Helena β”‚ β”‚ ErdΕ‘s β”œβ”€β”€β”€β”€β”€β”€ Shusaku β”‚
β””β”€β”€β”€β”¬β”€β”€β”€β”¬β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”˜ └───────┐ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
β”‚ Isla β”œβ”€β”€β”€β”€β”€β”€ Tariq β”‚ β”‚ Kevin β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚
β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”
β”‚ Uma β”‚ β”‚ Morphy β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

The degree of separation between Tariq and Uma is 3 (Tariq β†’ Helena β†’ Isla β†’ Uma).
There's no known relationship between Isla and [Kevin][six-bacons], as there is no connection in the given data.
The degree of separation between Tariq and Uma is 2 (Tariq β†’ Isla β†’ Uma).
There's no known relationship between Isla and Kevin, as there is no connection in the given data.
The degree of separation between Uma and Isla is 1.

~~~~exercism/note
Expand Down
Loading