commit 31bcba98257f27e4d2e4fdc5680ccf79e35631c4
parent 471c9144c0395fc09a48fe7427ea29313db60ab5
Author: Samir Parikh <noreply@samirparikh.com>
Date: Thu, 6 Jan 2022 01:01:32 +0000
solve all tests
Diffstat:
4 files changed, 163 insertions(+), 0 deletions(-)
diff --git a/rna-transcription/HELP.md b/rna-transcription/HELP.md
@@ -0,0 +1,35 @@
+# Help
+
+## Running the tests
+
+There is a Perl 5 script with the extension `.t`, which will be used to test
+your solution. You can run through the tests by using the command:
+
+```bash
+`prove .`
+```
+
+## Submitting your solution
+
+You can submit your solution using the `exercism submit RNA.pm` command.
+This command will upload your solution to the Exercism website and print the solution page's URL.
+
+It's possible to submit an incomplete solution which allows you to:
+
+- See how others have completed the exercise
+- Request help from a mentor
+
+## Need to get help?
+
+If you'd like help solving the exercise, check the following pages:
+
+- The [Perl 5 track's documentation](https://exercism.org/docs/tracks/perl5)
+- [Exercism's support channel on gitter](https://gitter.im/exercism/support)
+- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
+
+Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
+
+To get help if you're having trouble, you can use one of the following resources:
+
+- [/r/perl5](https://www.reddit.com/r/perl5) is the perl5 subreddit.
+- [StackOverflow](http://stackoverflow.com/questions/tagged/perl5) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.
+\ No newline at end of file
diff --git a/rna-transcription/README.md b/rna-transcription/README.md
@@ -0,0 +1,42 @@
+# Rna Transcription
+
+Welcome to Rna Transcription on Exercism's Perl 5 Track.
+If you need help running the tests or submitting your code, check out `HELP.md`.
+
+## Instructions
+
+Given a DNA strand, return its RNA complement (per RNA transcription).
+
+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 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:
+
+* `G` -> `C`
+* `C` -> `G`
+* `T` -> `A`
+* `A` -> `U`
+
+## Source
+
+### Created by
+
+- @szabgab
+
+### Contributed to by
+
+- @bistik
+- @kytrinyx
+- @m-dango
+- @rfilipo
+- @yanick
+
+### Based on
+
+Hyperphysics - http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html
+\ No newline at end of file
diff --git a/rna-transcription/RNA.pm b/rna-transcription/RNA.pm
@@ -0,0 +1,13 @@
+package RNA;
+use strict;
+use warnings;
+use Exporter qw<import>;
+our @EXPORT_OK = qw<to_rna>;
+
+sub to_rna {
+ my ($dna) = @_;
+ (my $rna = $dna) =~ tr/GCTA/CGAU/;
+ return $rna;
+}
+
+1;
diff --git a/rna-transcription/rna-transcription.t b/rna-transcription/rna-transcription.t
@@ -0,0 +1,71 @@
+#!/usr/bin/env perl
+use Test2::V0;
+use JSON::PP;
+use constant JSON => JSON::PP->new;
+
+use FindBin qw<$Bin>;
+use lib $Bin, "$Bin/local/lib/perl5";
+
+use RNA qw<to_rna>;
+
+my @test_cases = do { local $/; @{ JSON->decode(<DATA>) }; };
+plan 7;
+
+imported_ok qw<to_rna> or bail_out;
+
+for my $case (@test_cases) {
+ is to_rna( $case->{input}{dna} ), $case->{expected},
+ $case->{description};
+}
+
+__DATA__
+[
+ {
+ "description": "Empty RNA sequence",
+ "expected": "",
+ "input": {
+ "dna": ""
+ },
+ "property": "toRna"
+ },
+ {
+ "description": "RNA complement of cytosine is guanine",
+ "expected": "G",
+ "input": {
+ "dna": "C"
+ },
+ "property": "toRna"
+ },
+ {
+ "description": "RNA complement of guanine is cytosine",
+ "expected": "C",
+ "input": {
+ "dna": "G"
+ },
+ "property": "toRna"
+ },
+ {
+ "description": "RNA complement of thymine is adenine",
+ "expected": "A",
+ "input": {
+ "dna": "T"
+ },
+ "property": "toRna"
+ },
+ {
+ "description": "RNA complement of adenine is uracil",
+ "expected": "U",
+ "input": {
+ "dna": "A"
+ },
+ "property": "toRna"
+ },
+ {
+ "description": "RNA complement",
+ "expected": "UGCACCAGAAUU",
+ "input": {
+ "dna": "ACGTGGTCTTAA"
+ },
+ "property": "toRna"
+ }
+]