Translation is the third and final step of the Central Dogma: the ribosome reads mRNA three bases
at a time and chains the corresponding amino acids. Implementing the codon table by hand is how
you internalise the genetic code's redundancy — and why synonymous mutations can be silent.
Statement
Given an RNA string whose length is a multiple of 3, translate it into a protein string using the
standard genetic code. Read the RNA in non-overlapping codons from left to right, appending the
single-letter amino acid code for each.
Stop as soon as you reach a stop codon (UAA, UAG, UGA) and do not include it in the
output. Print the protein string on one line.
Input — read from standard input
Variable
Type
Description
rna
line 1
str
The RNA sequence to translate
length is a multiple of 3, <= 1000, uppercase A, C, G, U only
These variables are already read for you in the starter code on the right.
Output
str
the protein string in single-letter amino acid codes, stop codon excluded
Translates to MAMAPRTEINSTRING; the final UGA is a stop codon and is not printed.
Sample 2
Input
AUGUAA
Expected Output
M
AUG gives M, then UAA halts translation immediately.
Submit also runs your code against 4 hidden test cases.
Hidden inputs are never shown — if one fails you'll get its number and a description of the
mismatch, not the data.
Constraints
length(rna) is always a multiple of 3, and at most 1000
Uppercase A, C, G, U only
Translation halts at the first stop codon; the stop codon itself is not printed