Closed NobbZ closed 6 years ago
hmmm. I am wondering if I can even see that solution? I am not a mentor of the elixir track. I am not at my usual computer that has the CLI installed in order to try --uuid
. I'll try to check it out when I get a chance.
As the code has been fixed by the student in his/her latest iteration you won't be able to fetch the buggy code anymore.
The iteration in question is 3.
Can you drop the buggy code in a gist for accessibility?
I'll do so when I'm back home. 4h at least from now. We did a family short trip to the Baltic sea. So if it gets too late (living west of Hamburg) I'll post back tomorrow.
OK, the solution is here:
defmodule RNATranscription do
@doc """
Transcribes a character list representing DNA nucleotides to RNA
## Examples
iex> RNATranscription.to_rna('ACTG')
'UGAC'
"""
@transcription_map %{
(?G) => (?C),
(?C) => (?G),
(?T) => (?A),
(?A) => (?U)
}
# recursive solution -- slightly cleaner?
@spec to_rna([char]) :: [char]
def to_rna(dna) do
transcribe(dna)
end
def transcribe([nucleotide | dna_tail]) do
rna_complement = Map.get(@transcription_map, nucleotide)
transcribe(dna_tail, [rna_complement])
end
def transcribe([nucleotide | dna_tail], rna) do
rna_complement = Map.get(@transcription_map, nucleotide)
transcribe(dna_tail, [rna | [rna_complement]])
end
def transcribe([], rna_charlist) do
List.flatten(rna_charlist)
end
end
Today I mentored a solution, which passed the tests, but would fail on an "empty" DNA to transcribe.
elixir 2b5a441b2412424b9d8525d3df3283f9