Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Exercise: RNA Transcription #271

Closed
wants to merge 2 commits into from
Closed
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
18 changes: 17 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,23 @@
"practices": [],
"prerequisites": [],
"difficulty": 3
}
},
{
"slug": "rna-transcription",
"name": "RNA Transcription",
"uuid": "bc73c977-cd23-40f5-a890-773e12f71d01",
"practices": [],
"prerequisites": [],
"difficulty": 3
},
{
"slug": "triangle",
"name": "Triangle",
"uuid": "b916066b-918e-403c-9a9c-be33c4a6250d",
"practices": [],
"prerequisites": [],
"difficulty": 3
}
]
},
"concepts": [
Expand Down
20 changes: 20 additions & 0 deletions exercises/practice/rna-transcription/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Instructions

Your task is 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 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`

~~~~exercism/note
If you want to look at how the inputs and outputs are structured, take a look at the examples in the test suite.
~~~~
16 changes: 16 additions & 0 deletions exercises/practice/rna-transcription/.docs/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Introduction

You work for a bioengineering company that specializes in developing therapeutic solutions.

Your team has just been given a new project to develop a targeted therapy for a rare type of cancer.

~~~~exercism/note
It's all very complicated, but the basic idea is that sometimes people's bodies produce too much of a given protein.
That can cause all sorts of havoc.

But if you can create a very specific molecule (called a micro-RNA), it can prevent the protein from being produced.

This technique is called [RNA Interference][rnai].

[rnai]: https://admin.acceleratingscience.com/ask-a-scientist/what-is-rnai/
~~~~
13 changes: 13 additions & 0 deletions exercises/practice/rna-transcription/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"blurb": "Given a DNA strand, return its RNA Complement Transcription.",
"authors": ["ajborla"],
"contributors": [
],
"files": {
"solution": ["zcl_rna_transcription.clas.abap"],
"test": ["zcl_rna_transcription.clas.testclasses.abap"],
"example": [".meta/zcl_rna_transcription.clas.abap"]
},
"source": "Hyperphysics",
"source_url": "https://web.archive.org/web/20220408112140/http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
CLASS zcl_rna_transcription DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.

PUBLIC SECTION.
METHODS
transcribe
IMPORTING
strand TYPE string
RETURNING
VALUE(result) TYPE string.

PROTECTED SECTION.
PRIVATE SECTION.

ENDCLASS.


CLASS zcl_rna_transcription IMPLEMENTATION.

METHOD transcribe.
DATA(offset) = 0.
result = ''.
DO strlen( strand ) TIMES.
CASE strand+offset(1).
WHEN 'A'.
result = result && 'U'.
WHEN 'C'.
result = result && 'G'.
WHEN 'G'.
result = result && 'C'.
WHEN 'T'.
result = result && 'A'.
ENDCASE.
offset = offset + 1.
ENDDO.
ENDMETHOD.

ENDCLASS.
10 changes: 10 additions & 0 deletions exercises/practice/rna-transcription/package.devc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_DEVC" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<DEVC>
<CTEXT>Exercism: RNA Transcription</CTEXT>
</DEVC>
</asx:values>
</asx:abap>
</abapGit>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
CLASS zcl_rna_transcription DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.

PUBLIC SECTION.
METHODS
transcribe
IMPORTING
strand TYPE string
RETURNING
VALUE(result) TYPE string.

PROTECTED SECTION.
PRIVATE SECTION.

ENDCLASS.


CLASS zcl_rna_transcription IMPLEMENTATION.

METHOD transcribe.
"Implement solution
ENDMETHOD.

ENDCLASS.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
*"* use this source file for your ABAP unit test classes
CLASS ltcl_rna_transcription DEFINITION FINAL FOR TESTING
DURATION SHORT
RISK LEVEL HARMLESS.

PRIVATE SECTION.
DATA cut TYPE REF TO zcl_rna_transcription.
METHODS setup.
METHODS:
empty_rna_sequence FOR TESTING,
rna_cmp_of_cytosine_is_guanine FOR TESTING,
rna_cmp_of_guanine_is_cytosine FOR TESTING,
rna_cmp_of_thymine_is_adenine FOR TESTING,
rna_cmp_of_adenine_is_uracil FOR TESTING,
rna_complement FOR TESTING.
ENDCLASS.


CLASS ltcl_rna_transcription IMPLEMENTATION.
METHOD setup.
cut = NEW zcl_rna_transcription( ).
ENDMETHOD.

METHOD empty_rna_sequence.
cl_abap_unit_assert=>assert_equals(
exp = ''
act = cut->transcribe( '' ) ).
ENDMETHOD.

METHOD rna_cmp_of_cytosine_is_guanine.
cl_abap_unit_assert=>assert_equals(
exp = 'G'
act = cut->transcribe( 'C' ) ).
ENDMETHOD.

METHOD rna_cmp_of_guanine_is_cytosine.
cl_abap_unit_assert=>assert_equals(
exp = 'C'
act = cut->transcribe( 'G' ) ).
ENDMETHOD.

METHOD rna_cmp_of_thymine_is_adenine.
cl_abap_unit_assert=>assert_equals(
exp = 'A'
act = cut->transcribe( 'T' ) ).
ENDMETHOD.

METHOD rna_cmp_of_adenine_is_uracil.
cl_abap_unit_assert=>assert_equals(
exp = 'U'
act = cut->transcribe( 'A' ) ).
ENDMETHOD.

METHOD rna_complement.
cl_abap_unit_assert=>assert_equals(
exp = 'UGCACCAGAAUU'
act = cut->transcribe( 'ACGTGGTCTTAA' ) ).
ENDMETHOD.

ENDCLASS.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>ZCL_RNA_TRANSCRIPTION</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>Exercism: RNA Transcription</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
<WITH_UNIT_TESTS>X</WITH_UNIT_TESTS>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>
29 changes: 29 additions & 0 deletions exercises/practice/triangle/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Instructions

Determine if a triangle is equilateral, isosceles, or scalene.

An _equilateral_ triangle has all three sides the same length.

An _isosceles_ triangle has at least two sides the same length.
(It is sometimes specified as having exactly two sides the same length, but for the purposes of this exercise we'll say at least two.)

A _scalene_ triangle has all sides of different lengths.

## Note

For a shape to be a triangle at all, all sides have to be of length > 0, and the sum of the lengths of any two sides must be greater than or equal to the length of the third side.

In equations:

Let `a`, `b`, and `c` be sides of the triangle.
Then all three of the following expressions must be true:

```text
a + b ≥ c
b + c ≥ a
a + c ≥ b
```

See [Triangle Inequality][triangle-inequality]

[triangle-inequality]: https://en.wikipedia.org/wiki/Triangle_inequality
13 changes: 13 additions & 0 deletions exercises/practice/triangle/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"blurb": "Determine if a triangle is equilateral, isosceles, or scalene.",
"authors": ["ajborla"],
"contributors": [
],
"files": {
"solution": ["zcl_triangle.clas.abap"],
"test": ["zcl_triangle.clas.testclasses.abap"],
"example": [".meta/zcl_triangle.clas.abap"]
},
"source": "The Ruby Koans triangle project, parts 1 & 2",
"source_url": "https://web.archive.org/web/20220831105330/http://rubykoans.com"
}
Loading
Loading