Skip to content
Merged

Sync #746

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
2 changes: 1 addition & 1 deletion exercises/practice/luhn/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ If the sum is evenly divisible by 10, the original number is valid.

### Invalid Canadian SIN

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

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

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who let smart quotes in?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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)
80 changes: 51 additions & 29 deletions exercises/practice/variable-length-quantity/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,81 +1,103 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

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

[be44d299-a151-4604-a10e-d4b867f41540]
description = "arbitrary single byte"
description = "Encode a series of integers, producing a series of bytes. -> arbitrary single byte"

[890bc344-cb80-45af-b316-6806a6971e81]
description = "Encode a series of integers, producing a series of bytes. -> asymmetric single byte"

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

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

[63955a49-2690-4e22-a556-0040648d6b2d]
description = "arbitrary double byte"
description = "Encode a series of integers, producing a series of bytes. -> arbitrary double byte"

[4977d113-251b-4d10-a3ad-2f5a7756bb58]
description = "Encode a series of integers, producing a series of bytes. -> asymmetric double byte"

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

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

[5df0bc2d-2a57-4300-a653-a75ee4bd0bee]
description = "arbitrary triple byte"
description = "Encode a series of integers, producing a series of bytes. -> arbitrary triple byte"

[6731045f-1e00-4192-b5ae-98b22e17e9f7]
description = "Encode a series of integers, producing a series of bytes. -> asymmetric triple byte"

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

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

[11ed3469-a933-46f1-996f-2231e05d7bb6]
description = "arbitrary quadruple byte"
description = "Encode a series of integers, producing a series of bytes. -> arbitrary quadruple byte"

[b45ef770-cbba-48c2-bd3c-c6362679516e]
description = "Encode a series of integers, producing a series of bytes. -> asymmetric quadruple byte"

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

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

[5f34ff12-2952-4669-95fe-2d11b693d331]
description = "arbitrary quintuple byte"
description = "Encode a series of integers, producing a series of bytes. -> arbitrary quintuple byte"

[9be46731-7cd5-415c-b960-48061cbc1154]
description = "Encode a series of integers, producing a series of bytes. -> asymmetric quintuple byte"

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

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

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

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

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

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

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

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

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

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

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

[a91e6f5a-c64a-48e3-8a75-ce1a81e0ebee]
description = "multiple values"
description = "Decode a series of bytes, producing a series of integers. -> multiple values"
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bats
load bats-extra

# local version: 1.2.0.0

#
# *** Input and Output numbers are expressed in hexadecimal.
#
Expand All @@ -24,6 +22,13 @@ load bats-extra
assert_output "40"
}

@test "asymmetric single byte" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash variable_length_quantity.sh encode 53
assert_success
assert_output 53
}

@test "largest single byte" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash variable_length_quantity.sh encode 7F
Expand All @@ -45,6 +50,13 @@ load bats-extra
assert_output "C0 00"
}

@test "asymmetric double byte" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash variable_length_quantity.sh encode AD
assert_success
assert_output "81 2D"
}

@test "largest double byte" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash variable_length_quantity.sh encode 3FFF
Expand All @@ -66,6 +78,13 @@ load bats-extra
assert_output "C0 80 00"
}

@test "asymmetric triple byte" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash variable_length_quantity.sh encode 1D59C
assert_success
assert_output "87 AB 1C"
}

@test "largest triple byte" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash variable_length_quantity.sh encode 1FFFFF
Expand All @@ -87,6 +106,13 @@ load bats-extra
assert_output "C0 80 80 00"
}

@test "asymmetric quadruple byte" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash variable_length_quantity.sh encode 357704
assert_success
assert_output "81 D5 EE 04"
}

@test "largest quadruple byte" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash variable_length_quantity.sh encode FFFFFFF
Expand All @@ -108,6 +134,13 @@ load bats-extra
assert_output "8F F8 80 80 00"
}

@test "asymmetric quintuple byte" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash variable_length_quantity.sh encode 86656105
assert_success
assert_output "88 B3 95 C2 05"
}

@test "maximum 32-bit integer input" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash variable_length_quantity.sh encode FFFFFFFF
Expand Down
25 changes: 22 additions & 3 deletions exercises/practice/wordy/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
# This is an auto-generated file. Regular comments will be removed when this
# file is regenerated. Regenerating will not touch any manually added keys,
# so comments can be added in a "comment" key.
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

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

[18983214-1dfc-4ebd-ac77-c110dde699ce]
description = "just a zero"

[607c08ee-2241-4288-916d-dae5455c87e6]
description = "just a negative number"

[bb8c655c-cf42-4dfc-90e0-152fcfd8d4e0]
description = "addition"

[bb9f2082-171c-46ad-ad4e-c3f72087c1b5]
description = "addition with a left hand zero"

[6fa05f17-405a-4742-80ae-5d1a8edb0d5d]
description = "addition with a right hand zero"

[79e49e06-c5ae-40aa-a352-7a3a01f70015]
description = "more addition"

Expand Down
30 changes: 28 additions & 2 deletions exercises/practice/wordy/wordy.bats
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
#!/usr/bin/env bats
load bats-extra

# local version: 1.5.0.0

@test "just a number" {
#[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is 5?"
assert_success
assert_output "5"
}

@test "just a zero" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is 0?"
assert_success
assert_output "0"
}

@test "just a negative number" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is -123?"
assert_success
assert_output "-123"
}

@test "addition" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is 1 plus 1?"
assert_success
assert_output "2"
}

@test "addition with a left hand zero" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is 0 plus 2?"
assert_success
assert_output "2"
}

@test "addition with a right hand zero" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is 3 plus 0?"
assert_success
assert_output "3"
}

@test "more addition" {
[[ $BATS_RUN_SKIPPED == "true" ]] || skip
run bash wordy.sh "What is 53 plus 2?"
Expand Down