Skip to content

Commit 63f8de9

Browse files
authored
Exercise syncing (#823)
1 parent 61f4865 commit 63f8de9

File tree

6 files changed

+37
-8
lines changed

6 files changed

+37
-8
lines changed

exercises/practice/affine-cipher/.docs/instructions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ E(x) = (ai + b) mod m
1818

1919
Where:
2020

21-
- `i` is the letter's index from `0` to the length of the alphabet - 1
21+
- `i` is the letter's index from `0` to the length of the alphabet - 1.
2222
- `m` is the length of the alphabet.
2323
For the Roman alphabet `m` is `26`.
24-
- `a` and `b` are integers which make the encryption key
24+
- `a` and `b` are integers which make up the encryption key.
2525

2626
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]).
2727
In case `a` is not coprime to `m`, your program should indicate that this is an error.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
# Instructions
22

3-
Compute Pascal's triangle up to a given number of rows.
3+
Your task is to output the first N rows of Pascal's triangle.
44

5-
In Pascal's Triangle each number is computed by adding the numbers to the right and left of the current position in the previous row.
5+
[Pascal's triangle][wikipedia] is a triangular array of positive integers.
6+
7+
In Pascal's triangle, the number of values in a row is equal to its row number (which starts at one).
8+
Therefore, the first row has one value, the second row has two values, and so on.
9+
10+
The first (topmost) row has a single value: `1`.
11+
Subsequent rows' values are computed by adding the numbers directly to the right and left of the current position in the previous row.
12+
13+
If the previous row does _not_ have a value to the left or right of the current position (which only happens for the leftmost and rightmost positions), treat that position's value as zero (effectively "ignoring" it in the summation).
14+
15+
## Example
16+
17+
Let's look at the first 5 rows of Pascal's Triangle:
618

719
```text
820
1
921
1 1
1022
1 2 1
1123
1 3 3 1
1224
1 4 6 4 1
13-
# ... etc
1425
```
26+
27+
The topmost row has one value, which is `1`.
28+
29+
The leftmost and rightmost values have only one preceding position to consider, which is the position to its right respectively to its left.
30+
With the topmost value being `1`, it follows from this that all the leftmost and rightmost values are also `1`.
31+
32+
The other values all have two positions to consider.
33+
For example, the fifth row's (`1 4 6 4 1`) middle value is `6`, as the values to its left and right in the preceding row are `3` and `3`:
34+
35+
[wikipedia]: https://en.wikipedia.org/wiki/Pascal%27s_triangle

exercises/practice/pig-latin/.docs/instructions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ For example:
1919

2020
## Rule 2
2121

22-
If a word begins with a one or more consonants, first move those consonants to the end of the word and then add an `"ay"` sound to the end of the word.
22+
If a word begins with one or more consonants, first move those consonants to the end of the word and then add an `"ay"` sound to the end of the word.
2323

2424
For example:
2525

@@ -33,7 +33,7 @@ If a word starts with zero or more consonants followed by `"qu"`, first move tho
3333

3434
For example:
3535

36-
- `"quick"` -> `"ickqu"` -> `"ay"` (starts with `"qu"`, no preceding consonants)
36+
- `"quick"` -> `"ickqu"` -> `"ickquay"` (starts with `"qu"`, no preceding consonants)
3737
- `"square"` -> `"aresqu"` -> `"aresquay"` (starts with one consonant followed by `"qu`")
3838

3939
## Rule 4

exercises/practice/protein-translation/.meta/tests.toml

+3
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,6 @@ description = "Incomplete RNA sequence can't translate"
9191

9292
[43945cf7-9968-402d-ab9f-b8a28750b050]
9393
description = "Incomplete RNA sequence can translate if valid until a STOP codon"
94+
95+
[f6f92714-769f-4187-9524-e353e8a41a80]
96+
description = "Sequence of two non-STOP codons does not translate to a STOP codon"

exercises/practice/protein-translation/protein-translation-test.lisp

+5
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@
145145
(result (list "Tryptophan" "Cysteine" "Tyrosine")))
146146
(is (equal result (protein-translation:proteins strand)))))
147147

148+
(test sequence-of-two-non-stop-codons-does-not-translate-to-a-stop-codon
149+
(let ((strand "AUGAUG")
150+
(result (list "Methionine" "Methionine")))
151+
(is (equal result (protein-translation:proteins strand)))))
152+
148153
(test non-existing-codon-cant-translate
149154
(let ((strand "AAA"))
150155
(signals protein-translation:invalid-protein (protein-translation:proteins strand))))

exercises/practice/yacht/.meta/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
]
1818
},
1919
"blurb": "Score a single throw of dice in the game Yacht.",
20-
"source": "James Kilfiger, using wikipedia",
20+
"source": "James Kilfiger, using Wikipedia",
2121
"source_url": "https://en.wikipedia.org/wiki/Yacht_(dice_game)"
2222
}

0 commit comments

Comments
 (0)