new rna_transcription.rb according to comments

This commit is contained in:
Ben Harris 2018-03-04 12:35:23 -06:00
parent a177b61678
commit d8f97adbaf
1 changed files with 8 additions and 8 deletions

View File

@ -1,15 +1,15 @@
class Complement class Complement
PAIRS = {
"A" => "U",
"T" => "A",
"C" => "G",
"G" => "C"
}
def self.of_dna(dna) def self.of_dna(dna)
pairs = {
"A" => "U",
"T" => "A",
"C" => "G",
"G" => "C"
}
dna.each_char.reduce("") do |memo, char| dna.each_char.reduce("") do |memo, char|
return "" unless pairs.member?(char) break "" unless PAIRS.key?(char)
memo + pairs[char] memo + PAIRS[char]
end end
end end
end end