Skip to content

Commit a41aae6

Browse files
🤖 Auto-sync docs, metadata, and filepaths
1 parent 0069f0f commit a41aae6

File tree

10 files changed

+107
-141
lines changed

10 files changed

+107
-141
lines changed

exercises/practice/binary-search-tree/.docs/instructions.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,52 @@ All data in the left subtree is less than or equal to the current node's data, a
1919

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

22+
![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)
23+
24+
```text
2225
4
2326
/
2427
2
28+
```
2529

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

32+
![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)
33+
34+
```text
2835
4
2936
/ \
3037
2 6
38+
```
3139

3240
If we then added 3, it would look like this
3341

42+
![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)
43+
44+
```text
3445
4
3546
/ \
3647
2 6
3748
\
3849
3
50+
```
3951

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

54+
![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)
55+
56+
```text
4257
4
4358
/ \
4459
/ \
4560
2 6
4661
/ \ / \
4762
1 3 5 7
63+
```
64+
65+
## Credit
66+
67+
The images were created by [habere-et-dispertire][habere-et-dispertire] using [PGF/TikZ][pgf-tikz] by Till Tantau.
68+
69+
[habere-et-dispertire]: https://exercism.org/profiles/habere-et-dispertire
70+
[pgf-tikz]: https://en.wikipedia.org/wiki/PGF/TikZ

exercises/practice/luhn/.docs/instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If the sum is evenly divisible by 10, the original number is valid.
4141

4242
### Invalid Canadian SIN
4343

44-
The number to be checked is `066 123 468`.
44+
The number to be checked is `066 123 478`.
4545

4646
We start at the end of the number and double every second digit, beginning with the second digit from the right and moving left.
4747

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,17 @@
11
# Instructions
22

3-
Translate RNA sequences into proteins.
3+
Your job is to translate RNA sequences into proteins.
44

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

7-
RNA: `"AUGUUUUCU"` => translates to
8-
9-
Codons: `"AUG", "UUU", "UCU"`
10-
=> which become a protein with the following sequence =>
11-
12-
Protein: `"Methionine", "Phenylalanine", "Serine"`
13-
14-
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.
15-
If it works for one codon, the program should work for all of them.
16-
However, feel free to expand the list in the test suite to include them all.
17-
18-
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.
19-
20-
All subsequent codons after are ignored, like this:
21-
22-
RNA: `"AUGUUUUCUUAAAUG"` =>
23-
24-
Codons: `"AUG", "UUU", "UCU", "UAA", "AUG"` =>
25-
26-
Protein: `"Methionine", "Phenylalanine", "Serine"`
27-
28-
Note the stop codon `"UAA"` terminates the translation and the final methionine is not translated into the protein sequence.
29-
30-
Below are the codons and resulting amino acids needed for the exercise.
9+
In the real world, there are 64 codons, which in turn correspond to 20 amino acids.
10+
However, for this exercise, you’ll only use a few of the possible 64.
11+
They are listed below:
3112

3213
| Codon | Amino Acid |
33-
| :----------------- | :------------ |
14+
| ------------------ | ------------- |
3415
| AUG | Methionine |
3516
| UUU, UUC | Phenylalanine |
3617
| UUA, UUG | Leucine |
@@ -40,6 +21,18 @@ Below are the codons and resulting amino acids needed for the exercise.
4021
| UGG | Tryptophan |
4122
| UAA, UAG, UGA | STOP |
4223

24+
For example, the RNA string “AUGUUUUCU” has three codons: “AUG”, “UUU” and “UCU”.
25+
These map to Methionine, Phenylalanine, and Serine.
26+
27+
## “STOP” Codons
28+
29+
You’ll note from the table above that there are three **“STOP” codons**.
30+
If you encounter any of these codons, ignore the rest of the sequence — the protein is complete.
31+
32+
For example, “AUGUUUUCUUAAAUG” contains a STOP codon (“UAA”).
33+
Once we reach that point, we stop processing.
34+
We therefore only consider the part before it (i.e. “AUGUUUUCU”), not any further codons after it (i.e. “AUG”).
35+
4336
Learn more about [protein translation on Wikipedia][protein-translation].
4437

4538
[protein-translation]: https://en.wikipedia.org/wiki/Translation_(biology)
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Instructions
22

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

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

1516
```text
16-
┌──────────┐ ┌──────────┐ ┌───────────┐
17-
│ Helena │ │ Erdős │ │ Shusaku │
18-
└───┬───┬──┘ └─────┬────┘ └──────┬────┘
19-
┌───┘ └───────┐ └──────┬──────┘
20-
▼ ▼ ▼
21-
┌──────────┐ ┌────────┐ ┌──────────┐
22-
│ Isla │ │ Tariq │ │ Kevin │
23-
└────┬─────┘ └────┬───┘ └──────────┘
24-
▼ ▼
25-
┌─────────┐ ┌────────┐
17+
┌──────────┐ ┌──────────┐ ┌───────────┐
18+
│ Helena │ │ Erdős ├─────┤ Shusaku │
19+
└───┬───┬──┘ └─────┬────┘ └────┬──────┘
20+
┌───┘ └───────┐ └───────┬───────┘
21+
┌─────┴────┐ ┌────┴───┐ ┌─────┴────┐
22+
│ Isla ├─────┤ Tariq │ │ Kevin │
23+
└────┬─────┘ └────┬───┘ └──────────┘
24+
│ │
25+
┌────┴────┐ ┌────┴───┐
2626
│ Uma │ │ Morphy │
2727
└─────────┘ └────────┘
2828
```
2929

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

34-
```exercism/note
34+
~~~~exercism/note
3535
Isla and Tariq are siblings and have a separation of 1.
3636
Similarly, this implementation would report a separation of 2 from you to your father's brother.
37-
```
37+
~~~~
3838

3939
[six-bacons]: https://en.m.wikipedia.org/wiki/Six_Degrees_of_Kevin_Bacon

exercises/practice/relative-distance/.docs/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Your algorithm will determine the **degree of separation** between two individua
99

1010
Will your app help crown a perfect match?
1111

12-
[islendiga-app]: http://www.islendingaapp.is/information-in-english/
12+
[islendiga-app]: https://web.archive.org/web/20250816223614/http://www.islendingaapp.is/information-in-english/
Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,12 @@
11
# Instructions
22

3-
Given a number from 0 to 999,999,999,999, spell out that number in English.
3+
Given a number, your task is to express it in English words exactly as your friend should say it out loud.
4+
Yaʻqūb expects to use numbers from 0 up to 999,999,999,999.
45

5-
## Step 1
6+
Examples:
67

7-
Handle the basic case of 0 through 99.
8-
9-
If the input to the program is `22`, then the output should be `'twenty-two'`.
10-
11-
Your program should complain loudly if given a number outside the blessed range.
12-
13-
Some good test cases for this program are:
14-
15-
- 0
16-
- 14
17-
- 50
18-
- 98
19-
- -1
20-
- 100
21-
22-
### Extension
23-
24-
If you're on a Mac, shell out to Mac OS X's `say` program to talk out loud.
25-
If you're on Linux or Windows, eSpeakNG may be available with the command `espeak`.
26-
27-
## Step 2
28-
29-
Implement breaking a number up into chunks of thousands.
30-
31-
So `1234567890` should yield a list like 1, 234, 567, and 890, while the far simpler `1000` should yield just 1 and 0.
32-
33-
## Step 3
34-
35-
Now handle inserting the appropriate scale word between those chunks.
36-
37-
So `1234567890` should yield `'1 billion 234 million 567 thousand 890'`
38-
39-
The program must also report any values that are out of range.
40-
It's fine to stop at "trillion".
41-
42-
## Step 4
43-
44-
Put it all together to get nothing but plain English.
45-
46-
`12345` should give `twelve thousand three hundred forty-five`.
47-
48-
The program must also report any values that are out of range.
8+
- 0 → zero
9+
- 1 → one
10+
- 12 → twelve
11+
- 123 → one hundred twenty-three
12+
- 1,234 → one thousand two hundred thirty-four
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Introduction
2+
3+
Your friend Yaʻqūb works the counter at the busiest deli in town, slicing, weighing, and wrapping orders for a never-ending line of hungry customers.
4+
To keep things moving, each customer takes a numbered ticket when they arrive.
5+
6+
When it’s time to call the next person, Yaʻqūb reads their number out loud, always in full English words to make sure everyone hears it clearly.
Lines changed: 26 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,40 @@
11
# Instructions
22

3-
Implement a simple shift cipher like Caesar and a more secure substitution cipher.
3+
Create an implementation of the [Vigenère cipher][wiki].
4+
The Vigenère cipher is a simple substitution cipher.
45

5-
## Step 1
6+
## Cipher terminology
67

7-
"If he had anything confidential to say, he wrote it in cipher, that is, by so changing the order of the letters of the alphabet, that not a word could be made out.
8-
If anyone wishes to decipher these, and get at their meaning, he must substitute the fourth letter of the alphabet, namely D, for A, and so with the others."
9-
—Suetonius, Life of Julius Caesar
8+
A cipher is an algorithm used to encrypt, or encode, a string.
9+
The unencrypted string is called the _plaintext_ and the encrypted string is called the _ciphertext_.
10+
Converting plaintext to ciphertext is called _encoding_ while the reverse is called _decoding_.
1011

11-
Ciphers are very straight-forward algorithms that allow us to render text less readable while still allowing easy deciphering.
12-
They are vulnerable to many forms of cryptanalysis, but Caesar was lucky that his enemies were not cryptanalysts.
12+
In a _substitution cipher_, each plaintext letter is replaced with a ciphertext letter which is computed with the help of a _key_.
13+
(Note, it is possible for replacement letter to be the same as the original letter.)
1314

14-
The Caesar cipher was used for some messages from Julius Caesar that were sent afield.
15-
Now Caesar knew that the cipher wasn't very good, but he had one ally in that respect: almost nobody could read well.
16-
So even being a couple letters off was sufficient so that people couldn't recognize the few words that they did know.
15+
## Encoding details
1716

18-
Your task is to create a simple shift cipher like the Caesar cipher.
19-
This image is a great example of the Caesar cipher:
17+
In this cipher, the key is a series of lowercase letters, such as `"abcd"`.
18+
Each letter of the plaintext is _shifted_ or _rotated_ by a distance based on a corresponding letter in the key.
19+
An `"a"` in the key means a shift of 0 (that is, no shift).
20+
A `"b"` in the key means a shift of 1.
21+
A `"c"` in the key means a shift of 2, and so on.
2022

21-
![Caesar cipher][img-caesar-cipher]
23+
The first letter of the plaintext uses the first letter of the key, the second letter of the plaintext uses the second letter of the key and so on.
24+
If you run out of letters in the key before you run out of letters in the plaintext, start over from the start of the key again.
2225

23-
For example:
26+
If the key only contains one letter, such as `"dddddd"`, then all letters of the plaintext are shifted by the same amount (three in this example), which would make this the same as a rotational cipher or shift cipher (sometimes called a Caesar cipher).
27+
For example, the plaintext `"iamapandabear"` would become `"ldpdsdqgdehdu"`.
2428

25-
Giving "iamapandabear" as input to the encode function returns the cipher "ldpdsdqgdehdu".
26-
Obscure enough to keep our message secret in transit.
29+
If the key only contains the letter `"a"` (one or more times), the shift distance is zero and the ciphertext is the same as the plaintext.
2730

28-
When "ldpdsdqgdehdu" is put into the decode function it would return the original "iamapandabear" letting your friend read your original message.
31+
Usually the key is more complicated than that, though!
32+
If the key is `"abcd"` then letters of the plaintext would be shifted by a distance of 0, 1, 2, and 3.
33+
If the plaintext is `"hello"`, we need 5 shifts so the key would wrap around, giving shift distances of 0, 1, 2, 3, and 0.
34+
Applying those shifts to the letters of `"hello"` we get `"hfnoo"`.
2935

30-
## Step 2
36+
## Random keys
3137

32-
Shift ciphers quickly cease to be useful when the opposition commander figures them out.
33-
So instead, let's try using a substitution cipher.
34-
Try amending the code to allow us to specify a key and use that for the shift distance.
38+
If no key is provided, generate a key which consists of at least 100 random lowercase letters from the Latin alphabet.
3539

36-
Here's an example:
37-
38-
Given the key "aaaaaaaaaaaaaaaaaa", encoding the string "iamapandabear"
39-
would return the original "iamapandabear".
40-
41-
Given the key "ddddddddddddddddd", encoding our string "iamapandabear"
42-
would return the obscured "ldpdsdqgdehdu"
43-
44-
In the example above, we've set a = 0 for the key value.
45-
So when the plaintext is added to the key, we end up with the same message coming out.
46-
So "aaaa" is not an ideal key.
47-
But if we set the key to "dddd", we would get the same thing as the Caesar cipher.
48-
49-
## Step 3
50-
51-
The weakest link in any cipher is the human being.
52-
Let's make your substitution cipher a little more fault tolerant by providing a source of randomness and ensuring that the key contains only lowercase letters.
53-
54-
If someone doesn't submit a key at all, generate a truly random key of at least 100 lowercase characters in length.
55-
56-
## Extensions
57-
58-
Shift ciphers work by making the text slightly odd, but are vulnerable to frequency analysis.
59-
Substitution ciphers help that, but are still very vulnerable when the key is short or if spaces are preserved.
60-
Later on you'll see one solution to this problem in the exercise "crypto-square".
61-
62-
If you want to go farther in this field, the questions begin to be about how we can exchange keys in a secure way.
63-
Take a look at [Diffie-Hellman on Wikipedia][dh] for one of the first implementations of this scheme.
64-
65-
[img-caesar-cipher]: https://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/Caesar_cipher_left_shift_of_3.svg/320px-Caesar_cipher_left_shift_of_3.svg.png
66-
[dh]: https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange
40+
[wiki]: https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher

exercises/practice/simple-cipher/.meta/config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
".meta/proof.ci.ts"
2121
]
2222
},
23-
"blurb": "Implement a simple shift cipher like Caesar and a more secure substitution cipher.",
23+
"blurb": "Implement the Vigenère cipher, a simple substitution cipher.",
2424
"custom": {
2525
"version.tests.compatibility": "jest-29",
2626
"flag.tests.task-per-describe": false,
2727
"flag.tests.may-run-long": false,
2828
"flag.tests.includes-optional": false,
2929
"flag.tests.jest": true,
3030
"flag.tests.tstyche": false
31-
},
31+
}
3232
"source": "Substitution Cipher at Wikipedia",
3333
"source_url": "https://en.wikipedia.org/wiki/Substitution_cipher"
3434
}

exercises/practice/triangle/.docs/instructions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ A _scalene_ triangle has all sides of different lengths.
1313

1414
For a shape to be a triangle at all, all sides have to be of length > 0, and the sum of the lengths of any two sides must be greater than or equal to the length of the third side.
1515

16+
~~~~exercism/note
17+
_Degenerate triangles_ are triangles where the sum of the length of two sides is **equal** to the length of the third side, e.g. `1, 1, 2`.
18+
We opted to not include tests for degenerate triangles in this exercise.
19+
You may handle those situations if you wish to do so, or safely ignore them.
20+
~~~~
21+
1622
In equations:
1723

1824
Let `a`, `b`, and `c` be sides of the triangle.

0 commit comments

Comments
 (0)