Skip to content

Commit 4a60f77

Browse files
authored
Sync (#746)
* sync docs * sync tests for wordy * sync tests for variable-length-quantity
1 parent 784b989 commit 4a60f77

File tree

6 files changed

+157
-64
lines changed

6 files changed

+157
-64
lines changed

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: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,103 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[35c9db2e-f781-4c52-b73b-8e76427defd0]
6-
description = "zero"
13+
description = "Encode a series of integers, producing a series of bytes. -> zero"
714

815
[be44d299-a151-4604-a10e-d4b867f41540]
9-
description = "arbitrary single byte"
16+
description = "Encode a series of integers, producing a series of bytes. -> arbitrary single byte"
17+
18+
[890bc344-cb80-45af-b316-6806a6971e81]
19+
description = "Encode a series of integers, producing a series of bytes. -> asymmetric single byte"
1020

1121
[ea399615-d274-4af6-bbef-a1c23c9e1346]
12-
description = "largest single byte"
22+
description = "Encode a series of integers, producing a series of bytes. -> largest single byte"
1323

1424
[77b07086-bd3f-4882-8476-8dcafee79b1c]
15-
description = "smallest double byte"
25+
description = "Encode a series of integers, producing a series of bytes. -> smallest double byte"
1626

1727
[63955a49-2690-4e22-a556-0040648d6b2d]
18-
description = "arbitrary double byte"
28+
description = "Encode a series of integers, producing a series of bytes. -> arbitrary double byte"
29+
30+
[4977d113-251b-4d10-a3ad-2f5a7756bb58]
31+
description = "Encode a series of integers, producing a series of bytes. -> asymmetric double byte"
1932

2033
[29da7031-0067-43d3-83a7-4f14b29ed97a]
21-
description = "largest double byte"
34+
description = "Encode a series of integers, producing a series of bytes. -> largest double byte"
2235

2336
[3345d2e3-79a9-4999-869e-d4856e3a8e01]
24-
description = "smallest triple byte"
37+
description = "Encode a series of integers, producing a series of bytes. -> smallest triple byte"
2538

2639
[5df0bc2d-2a57-4300-a653-a75ee4bd0bee]
27-
description = "arbitrary triple byte"
40+
description = "Encode a series of integers, producing a series of bytes. -> arbitrary triple byte"
41+
42+
[6731045f-1e00-4192-b5ae-98b22e17e9f7]
43+
description = "Encode a series of integers, producing a series of bytes. -> asymmetric triple byte"
2844

2945
[f51d8539-312d-4db1-945c-250222c6aa22]
30-
description = "largest triple byte"
46+
description = "Encode a series of integers, producing a series of bytes. -> largest triple byte"
3147

3248
[da78228b-544f-47b7-8bfe-d16b35bbe570]
33-
description = "smallest quadruple byte"
49+
description = "Encode a series of integers, producing a series of bytes. -> smallest quadruple byte"
3450

3551
[11ed3469-a933-46f1-996f-2231e05d7bb6]
36-
description = "arbitrary quadruple byte"
52+
description = "Encode a series of integers, producing a series of bytes. -> arbitrary quadruple byte"
53+
54+
[b45ef770-cbba-48c2-bd3c-c6362679516e]
55+
description = "Encode a series of integers, producing a series of bytes. -> asymmetric quadruple byte"
3756

3857
[d5f3f3c3-e0f1-4e7f-aad0-18a44f223d1c]
39-
description = "largest quadruple byte"
58+
description = "Encode a series of integers, producing a series of bytes. -> largest quadruple byte"
4059

4160
[91a18b33-24e7-4bfb-bbca-eca78ff4fc47]
42-
description = "smallest quintuple byte"
61+
description = "Encode a series of integers, producing a series of bytes. -> smallest quintuple byte"
4362

4463
[5f34ff12-2952-4669-95fe-2d11b693d331]
45-
description = "arbitrary quintuple byte"
64+
description = "Encode a series of integers, producing a series of bytes. -> arbitrary quintuple byte"
65+
66+
[9be46731-7cd5-415c-b960-48061cbc1154]
67+
description = "Encode a series of integers, producing a series of bytes. -> asymmetric quintuple byte"
4668

4769
[7489694b-88c3-4078-9864-6fe802411009]
48-
description = "maximum 32-bit integer input"
70+
description = "Encode a series of integers, producing a series of bytes. -> maximum 32-bit integer input"
4971

5072
[f9b91821-cada-4a73-9421-3c81d6ff3661]
51-
description = "two single-byte values"
73+
description = "Encode a series of integers, producing a series of bytes. -> two single-byte values"
5274

5375
[68694449-25d2-4974-ba75-fa7bb36db212]
54-
description = "two multi-byte values"
76+
description = "Encode a series of integers, producing a series of bytes. -> two multi-byte values"
5577

5678
[51a06b5c-de1b-4487-9a50-9db1b8930d85]
57-
description = "many multi-byte values"
79+
description = "Encode a series of integers, producing a series of bytes. -> many multi-byte values"
5880

5981
[baa73993-4514-4915-bac0-f7f585e0e59a]
60-
description = "one byte"
82+
description = "Decode a series of bytes, producing a series of integers. -> one byte"
6183

6284
[72e94369-29f9-46f2-8c95-6c5b7a595aee]
63-
description = "two bytes"
85+
description = "Decode a series of bytes, producing a series of integers. -> two bytes"
6486

6587
[df5a44c4-56f7-464e-a997-1db5f63ce691]
66-
description = "three bytes"
88+
description = "Decode a series of bytes, producing a series of integers. -> three bytes"
6789

6890
[1bb58684-f2dc-450a-8406-1f3452aa1947]
69-
description = "four bytes"
91+
description = "Decode a series of bytes, producing a series of integers. -> four bytes"
7092

7193
[cecd5233-49f1-4dd1-a41a-9840a40f09cd]
72-
description = "maximum 32-bit integer"
94+
description = "Decode a series of bytes, producing a series of integers. -> maximum 32-bit integer"
7395

7496
[e7d74ba3-8b8e-4bcb-858d-d08302e15695]
75-
description = "incomplete sequence causes error"
97+
description = "Decode a series of bytes, producing a series of integers. -> incomplete sequence causes error"
7698

7799
[aa378291-9043-4724-bc53-aca1b4a3fcb6]
78-
description = "incomplete sequence causes error, even if value is zero"
100+
description = "Decode a series of bytes, producing a series of integers. -> incomplete sequence causes error, even if value is zero"
79101

80102
[a91e6f5a-c64a-48e3-8a75-ce1a81e0ebee]
81-
description = "multiple values"
103+
description = "Decode a series of bytes, producing a series of integers. -> multiple values"

exercises/practice/variable-length-quantity/variable_length_quantity.bats

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env bats
22
load bats-extra
33

4-
# local version: 1.2.0.0
5-
64
#
75
# *** Input and Output numbers are expressed in hexadecimal.
86
#
@@ -24,6 +22,13 @@ load bats-extra
2422
assert_output "40"
2523
}
2624

25+
@test "asymmetric single byte" {
26+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
27+
run bash variable_length_quantity.sh encode 53
28+
assert_success
29+
assert_output 53
30+
}
31+
2732
@test "largest single byte" {
2833
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
2934
run bash variable_length_quantity.sh encode 7F
@@ -45,6 +50,13 @@ load bats-extra
4550
assert_output "C0 00"
4651
}
4752

53+
@test "asymmetric double byte" {
54+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
55+
run bash variable_length_quantity.sh encode AD
56+
assert_success
57+
assert_output "81 2D"
58+
}
59+
4860
@test "largest double byte" {
4961
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
5062
run bash variable_length_quantity.sh encode 3FFF
@@ -66,6 +78,13 @@ load bats-extra
6678
assert_output "C0 80 00"
6779
}
6880

81+
@test "asymmetric triple byte" {
82+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
83+
run bash variable_length_quantity.sh encode 1D59C
84+
assert_success
85+
assert_output "87 AB 1C"
86+
}
87+
6988
@test "largest triple byte" {
7089
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
7190
run bash variable_length_quantity.sh encode 1FFFFF
@@ -87,6 +106,13 @@ load bats-extra
87106
assert_output "C0 80 80 00"
88107
}
89108

109+
@test "asymmetric quadruple byte" {
110+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
111+
run bash variable_length_quantity.sh encode 357704
112+
assert_success
113+
assert_output "81 D5 EE 04"
114+
}
115+
90116
@test "largest quadruple byte" {
91117
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
92118
run bash variable_length_quantity.sh encode FFFFFFF
@@ -108,6 +134,13 @@ load bats-extra
108134
assert_output "8F F8 80 80 00"
109135
}
110136

137+
@test "asymmetric quintuple byte" {
138+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
139+
run bash variable_length_quantity.sh encode 86656105
140+
assert_success
141+
assert_output "88 B3 95 C2 05"
142+
}
143+
111144
@test "maximum 32-bit integer input" {
112145
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
113146
run bash variable_length_quantity.sh encode FFFFFFFF

exercises/practice/wordy/.meta/tests.toml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[88bf4b28-0de3-4883-93c7-db1b14aa806e]
613
description = "just a number"
714

15+
[18983214-1dfc-4ebd-ac77-c110dde699ce]
16+
description = "just a zero"
17+
18+
[607c08ee-2241-4288-916d-dae5455c87e6]
19+
description = "just a negative number"
20+
821
[bb8c655c-cf42-4dfc-90e0-152fcfd8d4e0]
922
description = "addition"
1023

24+
[bb9f2082-171c-46ad-ad4e-c3f72087c1b5]
25+
description = "addition with a left hand zero"
26+
27+
[6fa05f17-405a-4742-80ae-5d1a8edb0d5d]
28+
description = "addition with a right hand zero"
29+
1130
[79e49e06-c5ae-40aa-a352-7a3a01f70015]
1231
description = "more addition"
1332

exercises/practice/wordy/wordy.bats

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,48 @@
11
#!/usr/bin/env bats
22
load bats-extra
33

4-
# local version: 1.5.0.0
5-
64
@test "just a number" {
75
#[[ $BATS_RUN_SKIPPED == "true" ]] || skip
86
run bash wordy.sh "What is 5?"
97
assert_success
108
assert_output "5"
119
}
1210

11+
@test "just a zero" {
12+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
13+
run bash wordy.sh "What is 0?"
14+
assert_success
15+
assert_output "0"
16+
}
17+
18+
@test "just a negative number" {
19+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
20+
run bash wordy.sh "What is -123?"
21+
assert_success
22+
assert_output "-123"
23+
}
24+
1325
@test "addition" {
1426
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
1527
run bash wordy.sh "What is 1 plus 1?"
1628
assert_success
1729
assert_output "2"
1830
}
1931

32+
@test "addition with a left hand zero" {
33+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
34+
run bash wordy.sh "What is 0 plus 2?"
35+
assert_success
36+
assert_output "2"
37+
}
38+
39+
@test "addition with a right hand zero" {
40+
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
41+
run bash wordy.sh "What is 3 plus 0?"
42+
assert_success
43+
assert_output "3"
44+
}
45+
2046
@test "more addition" {
2147
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
2248
run bash wordy.sh "What is 53 plus 2?"

0 commit comments

Comments
 (0)