From 13ed379b26c9774c14933fa23dd4fff7971bcb5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=20Nagy?= <20251272+BNAndras@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:25:15 -0800 Subject: [PATCH] Sync metadata, tests, and docs --- exercises/practice/bob/.meta/example.coffee | 14 +++-- exercises/practice/bob/.meta/tests.toml | 5 ++ exercises/practice/bob/bob.spec.coffee | 63 ++++++++++++++++--- .../practice/hamming/.docs/instructions.md | 11 ---- .../practice/hamming/.docs/introduction.md | 12 ++++ exercises/practice/hamming/.meta/config.json | 2 +- .../protein-translation/.docs/instructions.md | 8 +-- .../rna-transcription/.docs/instructions.md | 6 +- .../square-root/.docs/instructions.md | 17 +++-- .../square-root/.docs/introduction.md | 10 +++ .../practice/sublist/.docs/instructions.md | 4 +- 11 files changed, 110 insertions(+), 42 deletions(-) create mode 100644 exercises/practice/hamming/.docs/introduction.md create mode 100644 exercises/practice/square-root/.docs/introduction.md diff --git a/exercises/practice/bob/.meta/example.coffee b/exercises/practice/bob/.meta/example.coffee index bcc3d2bd..c1b10434 100644 --- a/exercises/practice/bob/.meta/example.coffee +++ b/exercises/practice/bob/.meta/example.coffee @@ -1,8 +1,10 @@ class Bob - hey: (message) -> switch - when message.trim() == "" then "Fine. Be that way!" - when message.match(/[a-zA-Z]/) and message == message.toUpperCase() and message[message.length - 1] == "?" then "Calm down, I know what I'm doing!" - when message.match(/[a-zA-Z]/) and message == message.toUpperCase() then "Whoa, chill out!" - when message[message.length - 1] == "?" then "Sure." - else "Whatever." + hey: (message) -> + message = message.trim() + switch + when message == "" then "Fine. Be that way!" + when message.match(/[a-zA-Z]/) and message == message.toUpperCase() and message[message.length - 1] == "?" then "Calm down, I know what I'm doing!" + when message.match(/[a-zA-Z]/) and message == message.toUpperCase() then "Whoa, chill out!" + when message[message.length - 1] == "?" then "Sure." + else "Whatever." module.exports = Bob diff --git a/exercises/practice/bob/.meta/tests.toml b/exercises/practice/bob/.meta/tests.toml index ea47d6bb..5299e289 100644 --- a/exercises/practice/bob/.meta/tests.toml +++ b/exercises/practice/bob/.meta/tests.toml @@ -71,6 +71,7 @@ description = "alternate silence" [66953780-165b-4e7e-8ce3-4bcb80b6385a] description = "multiple line question" +include = false [5371ef75-d9ea-4103-bcfa-2da973ddec1b] description = "starting with whitespace" @@ -83,3 +84,7 @@ description = "other whitespace" [12983553-8601-46a8-92fa-fcaa3bc4a2a0] description = "non-question ending with whitespace" + +[2c7278ac-f955-4eb4-bf8f-e33eb4116a15] +description = "multiple line question" +reimplements = "66953780-165b-4e7e-8ce3-4bcb80b6385a" diff --git a/exercises/practice/bob/bob.spec.coffee b/exercises/practice/bob/bob.spec.coffee index 8ff21b0f..3823ac23 100644 --- a/exercises/practice/bob/bob.spec.coffee +++ b/exercises/practice/bob/bob.spec.coffee @@ -1,4 +1,5 @@ Bob = require './bob' + describe 'Bob', -> bob = new Bob() it 'stating something', -> @@ -9,19 +10,31 @@ describe 'Bob', -> result = bob.hey 'WATCH OUT!' expect(result).toEqual 'Whoa, chill out!' + xit 'shouting gibberish', -> + result = bob.hey 'FCECDFCAAB' + expect(result).toEqual 'Whoa, chill out!' + xit 'asking a question', -> result = bob.hey 'Does this cryogenic chamber make me look fat?' expect(result).toEqual 'Sure.' + xit 'asking a numeric question', -> + result = bob.hey 'You are, what, like 15?' + expect(result).toEqual 'Sure.' + + xit 'asking gibberish', -> + result = bob.hey 'fffbbcbeab?' + expect(result).toEqual 'Sure.' + xit 'talking forcefully', -> - result = bob.hey "Let's go make out behind the gym!" + result = bob.hey 'Hi there!' expect(result).toEqual 'Whatever.' xit 'using acronyms in regular speech', -> - result = bob.hey "It's OK if you don't want to go to the DMV." + result = bob.hey "It's OK if you don't want to go work for NASA." expect(result).toEqual 'Whatever.' - xit 'forceful questions', -> + xit 'forceful question', -> result = bob.hey "WHAT'S GOING ON?" expect(result).toEqual "Calm down, I know what I'm doing!" @@ -29,24 +42,32 @@ describe 'Bob', -> result = bob.hey '1, 2, 3 GO!' expect(result).toEqual 'Whoa, chill out!' - xit 'only number', -> + xit 'no letters', -> result = bob.hey '1, 2, 3' expect(result).toEqual 'Whatever.' + xit 'question with no letters', -> + result = bob.hey '4?' + expect(result).toEqual 'Sure.' + xit 'shouting with special characters', -> - result = bob.hey 'ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!' + result = bob.hey 'ZOMG THE %^*@ #$(*^ ZOMBIES ARE COMING!!11!!1!' expect(result).toEqual 'Whoa, chill out!' xit 'shouting with no exclamation mark', -> - result = bob.hey 'I HATE YOU' + result = bob.hey 'I HATE THE DENTIST' expect(result).toEqual 'Whoa, chill out!' xit 'statement containing question mark', -> - result = bob.hey 'Ending with a ? means a question.' + result = bob.hey 'Ending with ? means a question.' expect(result).toEqual 'Whatever.' + xit 'non-letters with question', -> + result = bob.hey ':) ?' + expect(result).toEqual 'Sure.' + xit 'prattling on', -> - result = bob.hey 'Wait! Hang on. Are you going to be OK?' + result = bob.hey 'Wait! Hang on. Are you going to be OK?' expect(result).toEqual 'Sure.' xit 'silence', -> @@ -54,5 +75,29 @@ describe 'Bob', -> expect(result).toEqual 'Fine. Be that way!' xit 'prolonged silence', -> - result = bob.hey ' ' + result = bob.hey ' ' expect(result).toEqual 'Fine. Be that way!' + + xit 'alternate silence', -> + result = bob.hey '\t\t\t\t\t\t\t\t\t\t' + expect(result).toEqual 'Fine. Be that way!' + + xit 'multiple line question', -> + result = bob.hey "\nDoes this cryogenic chamber make\n me look fat?" + expect(result).toEqual 'Sure.' + + xit 'starting with whitespace', -> + result = bob.hey ' hmmmmmmm...' + expect(result).toEqual 'Whatever.' + + xit 'ending with whitespace', -> + result = bob.hey 'Okay if like my spacebar quite a bit? ' + expect(result).toEqual 'Sure.' + + xit 'other whitespace', -> + result = bob.hey "\n\r \t" + expect(result).toEqual 'Fine. Be that way!' + + xit 'non-question ending with whitespace', -> + result = bob.hey 'This is a statement ending with whitespace ' + expect(result).toEqual 'Whatever.' diff --git a/exercises/practice/hamming/.docs/instructions.md b/exercises/practice/hamming/.docs/instructions.md index b9ae6efc..8f47a179 100644 --- a/exercises/practice/hamming/.docs/instructions.md +++ b/exercises/practice/hamming/.docs/instructions.md @@ -2,15 +2,6 @@ Calculate the Hamming distance between two DNA strands. -Your body is made up of cells that contain DNA. -Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. -In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime! - -When cells divide, their DNA replicates too. -Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. -If we compare two strands of DNA and count the differences between them we can see how many mistakes occurred. -This is known as the "Hamming distance". - We read DNA using the letters C, A, G and T. Two strands might look like this: @@ -20,8 +11,6 @@ Two strands might look like this: They have 7 differences, and therefore the Hamming distance is 7. -The Hamming distance is useful for lots of things in science, not just biology, so it's a nice phrase to be familiar with :) - ## Implementation notes The Hamming distance is only defined for sequences of equal length, so an attempt to calculate it between sequences of different lengths should not work. diff --git a/exercises/practice/hamming/.docs/introduction.md b/exercises/practice/hamming/.docs/introduction.md new file mode 100644 index 00000000..8419bf47 --- /dev/null +++ b/exercises/practice/hamming/.docs/introduction.md @@ -0,0 +1,12 @@ +# Introduction + +Your body is made up of cells that contain DNA. +Those cells regularly wear out and need replacing, which they achieve by dividing into daughter cells. +In fact, the average human body experiences about 10 quadrillion cell divisions in a lifetime! + +When cells divide, their DNA replicates too. +Sometimes during this process mistakes happen and single pieces of DNA get encoded with the incorrect information. +If we compare two strands of DNA and count the differences between them, we can see how many mistakes occurred. +This is known as the "Hamming distance". + +The Hamming distance is useful in many areas of science, not just biology, so it's a nice phrase to be familiar with :) diff --git a/exercises/practice/hamming/.meta/config.json b/exercises/practice/hamming/.meta/config.json index 3d958a53..a94e66dd 100644 --- a/exercises/practice/hamming/.meta/config.json +++ b/exercises/practice/hamming/.meta/config.json @@ -13,7 +13,7 @@ ".meta/example.coffee" ] }, - "blurb": "Calculate the Hamming difference between two DNA strands.", + "blurb": "Calculate the Hamming distance between two DNA strands.", "source": "The Calculating Point Mutations problem at Rosalind", "source_url": "https://rosalind.info/problems/hamm/" } diff --git a/exercises/practice/protein-translation/.docs/instructions.md b/exercises/practice/protein-translation/.docs/instructions.md index 7dc34d2e..44880802 100644 --- a/exercises/practice/protein-translation/.docs/instructions.md +++ b/exercises/practice/protein-translation/.docs/instructions.md @@ -2,12 +2,12 @@ Translate RNA sequences into proteins. -RNA can be broken into three nucleotide sequences called codons, and then translated to a polypeptide like so: +RNA can be broken into three-nucleotide sequences called codons, and then translated to a protein like so: RNA: `"AUGUUUUCU"` => translates to Codons: `"AUG", "UUU", "UCU"` -=> which become a polypeptide with the following sequence => +=> which become a protein with the following sequence => Protein: `"Methionine", "Phenylalanine", "Serine"` @@ -27,9 +27,9 @@ 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. +Below are the codons and resulting amino acids needed for the exercise. -| Codon | Protein | +| Codon | Amino Acid | | :----------------- | :------------ | | AUG | Methionine | | UUU, UUC | Phenylalanine | diff --git a/exercises/practice/rna-transcription/.docs/instructions.md b/exercises/practice/rna-transcription/.docs/instructions.md index 36da381f..4dbfd3a2 100644 --- a/exercises/practice/rna-transcription/.docs/instructions.md +++ b/exercises/practice/rna-transcription/.docs/instructions.md @@ -1,12 +1,12 @@ # Instructions -Your task is determine the RNA complement of a given DNA sequence. +Your task is to determine the RNA complement of a given DNA sequence. Both DNA and RNA strands are a sequence of nucleotides. -The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), guanine (**G**) and thymine (**T**). +The four nucleotides found in DNA are adenine (**A**), cytosine (**C**), guanine (**G**), and thymine (**T**). -The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), guanine (**G**) and uracil (**U**). +The four nucleotides found in RNA are adenine (**A**), cytosine (**C**), guanine (**G**), and uracil (**U**). Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement: diff --git a/exercises/practice/square-root/.docs/instructions.md b/exercises/practice/square-root/.docs/instructions.md index e9905e9d..d258b868 100644 --- a/exercises/practice/square-root/.docs/instructions.md +++ b/exercises/practice/square-root/.docs/instructions.md @@ -1,13 +1,18 @@ # Instructions -Given a natural radicand, return its square root. +Your task is to calculate the square root of a given number. -Note that the term "radicand" refers to the number for which the root is to be determined. -That is, it is the number under the root symbol. +- Try to avoid using the pre-existing math libraries of your language. +- As input you'll be given a positive whole number, i.e. 1, 2, 3, 4… +- You are only required to handle cases where the result is a positive whole number. -Check out the Wikipedia pages on [square root][square-root] and [methods of computing square roots][computing-square-roots]. +Some potential approaches: -Recall also that natural numbers are positive real whole numbers (i.e. 1, 2, 3 and up). +- Linear or binary search for a number that gives the input number when squared. +- Successive approximation using Newton's or Heron's method. +- Calculating one digit at a time or one bit at a time. -[square-root]: https://en.wikipedia.org/wiki/Square_root +You can check out the Wikipedia pages on [integer square root][integer-square-root] and [methods of computing square roots][computing-square-roots] to help with choosing a method of calculation. + +[integer-square-root]: https://en.wikipedia.org/wiki/Integer_square_root [computing-square-roots]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots diff --git a/exercises/practice/square-root/.docs/introduction.md b/exercises/practice/square-root/.docs/introduction.md new file mode 100644 index 00000000..1d692934 --- /dev/null +++ b/exercises/practice/square-root/.docs/introduction.md @@ -0,0 +1,10 @@ +# Introduction + +We are launching a deep space exploration rocket and we need a way to make sure the navigation system stays on target. + +As the first step in our calculation, we take a target number and find its square root (that is, the number that when multiplied by itself equals the target number). + +The journey will be very long. +To make the batteries last as long as possible, we had to make our rocket's onboard computer very power efficient. +Unfortunately that means that we can't rely on fancy math libraries and functions, as they use more power. +Instead we want to implement our own square root calculation. diff --git a/exercises/practice/sublist/.docs/instructions.md b/exercises/practice/sublist/.docs/instructions.md index 7535931a..8228edc6 100644 --- a/exercises/practice/sublist/.docs/instructions.md +++ b/exercises/practice/sublist/.docs/instructions.md @@ -8,8 +8,8 @@ Given any two lists `A` and `B`, determine if: - None of the above is true, thus lists `A` and `B` are unequal Specifically, list `A` is equal to list `B` if both lists have the same values in the same order. -List `A` is a superlist of `B` if `A` contains a sub-sequence of values equal to `B`. -List `A` is a sublist of `B` if `B` contains a sub-sequence of values equal to `A`. +List `A` is a superlist of `B` if `A` contains a contiguous sub-sequence of values equal to `B`. +List `A` is a sublist of `B` if `B` contains a contiguous sub-sequence of values equal to `A`. Examples: